﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data.SqlClient;
using System.Configuration;
using System.Web.Security;
using System.Data;
using System.Collections;
using System.Web.UI.WebControls;
using MySql.Data.MySqlClient;
/// <summary>
///sql 的摘要说明
/// </summary>
/// 
public class sql
{
    private SqlConnection MyConnection;

    public sql()
    {
        //
        //TODO: 在此处添加构造函数逻辑
        //
    }

    /// <summary>
    /// 打开数据库连接
    /// </summary>
    /// <returns></returns>
    private SqlConnection Open()
    {
        if (MyConnection == null)
        {
            MyConnection = new SqlConnection(ConfigurationManager.AppSettings["ConnectionString"]);
            MyConnection.Open();
        }
        if (MyConnection.State == System.Data.ConnectionState.Closed)
            MyConnection.Open();
        return MyConnection;
    }

    /// <summary>
    /// 关闭数据库连接
    /// </summary>
    private void Close()
    {
        if (MyConnection != null)
        {
            MyConnection.Close();
            MyConnection = null;
        }
    }

    /// <summary>
    /// 写日志
    /// </summary>
    /// <param name="uid"></param>
    /// <param name="type"></param>
    /// <param name="ip"></param>
    /// <param name="memo"></param>
    /// <param name="MyCommand"></param>
    private void WriteLog(string uid, int type, string ip, string memo, SqlCommand MyCommand)
    {
        MyCommand.CommandText = "insert into syslog (sl_type,sl_man,sl_time,sl_ip,sl_memo) values (@sl_type,@sl_man,getdate(),@sl_ip,@sl_memo)";
        MyCommand.Parameters.Add("@sl_type", SqlDbType.Int).Value = type;
        MyCommand.Parameters.Add("@sl_man", SqlDbType.NVarChar).Value = uid;
        MyCommand.Parameters.Add("@sl_ip", SqlDbType.NVarChar).Value = ip;
        MyCommand.Parameters.Add("@sl_memo", SqlDbType.NVarChar).Value = memo;
        try
        {
            MyCommand.ExecuteNonQuery();
        }
        catch (Exception e)
        {
            throw e;
        }
    }

    /// <summary>
    /// 判断是否登录
    /// </summary>
    /// <param name="su_login"></param>
    /// <returns></returns>
    public DataTable CheckLogin(string su_login)
    {
        Open();
        SqlCommand MyCommand = new SqlCommand();
        MyCommand.Connection = MyConnection;
        MyCommand.CommandText = "select * from systemuser where su_login=@su_login ";
        MyCommand.Parameters.Add("@su_login", SqlDbType.NVarChar).Value = su_login;

        DataTable data = new DataTable();
        SqlDataAdapter adapter = new SqlDataAdapter(MyCommand);
        adapter.Fill(data);
        Close();
        return (data);
    }

    /// <summary>
    /// 判断是否有权限
    /// </summary>
    /// <returns></returns>
    public bool CheckPower(string su_no, string ml_no)
    {
        bool res = false;
        Open();
        try
        {
            if (string.IsNullOrEmpty(su_no))
            {
                Close();
                return false;
            }
            SqlCommand MyCommand = new SqlCommand("select * from systemuser,actorpower where su_no=@su_no and ap_acno=su_power and ap_mlno in (" + ml_no + ")", MyConnection);
            MyCommand.Parameters.Add("@su_no", SqlDbType.Int).Value = su_no;
            SqlDataReader dr = MyCommand.ExecuteReader();
            dr.Read();
            if (dr.HasRows)
                res = true;
            dr.Close();
        }
        catch (Exception e)
        {
            res = false;
        }
        Close();
        return (res);
    }

    /// <summary>
    /// 修改密码
    /// </summary>
    /// <param name="data"></param>
    /// <returns></returns>
    public int ChangePW(Hashtable data)
    {
        int res;
        Open();
        SqlCommand MyCommand = MyConnection.CreateCommand();
        SqlTransaction MyTrans;
        MyTrans = MyConnection.BeginTransaction("Tran");
        MyCommand.Connection = MyConnection;
        MyCommand.Transaction = MyTrans;
        try
        {
            MyCommand.CommandText = " select * from systemuser where su_no=@su_no ";
            MyCommand.Parameters.Add("@su_no", SqlDbType.BigInt).Value = data["user"];
            DataTable dt = new DataTable();
            SqlDataAdapter da = new SqlDataAdapter(MyCommand);
            da.Fill(dt);
            if (dt == null || dt.Rows.Count == 0)
            {
                Close();
                return 0;
            }
            else
            {
                if (!FormsAuthentication.HashPasswordForStoringInConfigFile(data["su_pwd"].ToString(), "MD5").ToLower().Equals(dt.Rows[0]["su_pwd"].ToString()))
                {
                    Close();
                    return -2;
                }
                else
                {
                    MyCommand.CommandText = " update systemuser set su_pwd=@su_pwd where su_no=@su_no ";
                    MyCommand.Parameters.Add("@su_pwd", SqlDbType.NVarChar).Value = FormsAuthentication.HashPasswordForStoringInConfigFile(data["new_pwd"].ToString(), "MD5").ToLower();
                    res = MyCommand.ExecuteNonQuery();
                    if (res > 0)
                        WriteLog(data["user"].ToString(), 2, data["ip"].ToString(), "用户【" + data["name"].ToString() + "】进行了修改密码操作。", MyCommand);
                    MyTrans.Commit();
                }
            }
        }
        catch
        {
            MyTrans.Rollback("Tran");
            res = -1;
        }
        Close();
        return res;
    }

    /// <summary>
    /// 登录
    /// </summary>
    /// <param name="uid"></param>
    /// <param name="name"></param>
    /// <param name="ip"></param>
    public void Login(string uid, string name, string ip)
    {
        Open();
        SqlCommand MyCommand = new SqlCommand();
        MyCommand.Connection = MyConnection;
        try
        {
            MyCommand.CommandText = " update systemuser set su_lastlogintime=su_logintime,su_lastloginip=su_loginip,su_loginnum=su_loginnum+1,su_logintime=getdate(),su_loginip=@ip where su_no=@su_no ";
            MyCommand.Parameters.Add("@su_no", SqlDbType.BigInt).Value = uid;
            MyCommand.Parameters.Add("@ip", SqlDbType.NVarChar).Value = ip;
            int res = MyCommand.ExecuteNonQuery();
            if (res > 0)
                WriteLog(uid, 0, ip, "用户【" + name + "】登录系统。", MyCommand);
        }
        catch (Exception e)
        {
        }
        Close();
    }

    /// <summary>
    /// 注销
    /// </summary>
    /// <param name="uid"></param>
    /// <param name="name"></param>
    /// <param name="ip"></param>
    public void Logout(string uid, string name, string ip)
    {
        Open();
        SqlCommand MyCommand = new SqlCommand();
        MyCommand.Connection = MyConnection;
        try
        {
            WriteLog(uid, 4, ip, "用户【" + name + "】注销系统。", MyCommand);
        }
        catch (Exception e)
        {
        }
        Close();
    }

    /// <summary>
    /// 分页存储过程
    /// </summary>
    /// <param name="TableName"></param>
    /// <param name="ReturnFields"></param>
    /// <param name="Where"></param>
    /// <param name="OrderFieldName"></param>
    /// <param name="OrderType"></param>
    /// <param name="PageSize"></param>
    /// <param name="CurPage"></param>
    /// <param name="tempno"></param>
    /// <param name="RowCount"></param>
    /// <returns></returns>
    public DataTable PagingTable(string TableName, string ReturnFields, string Where, string OrderFieldName, string OrderType, int PageSize, int CurPage, string tempno, out int RowCount)
    {
        Open();
        SqlParameter[] parameters = {
                  new SqlParameter("@Table", TableName),//表名
                  new SqlParameter("@TIndex", tempno),//主表KEY
                  new SqlParameter("@Column", ReturnFields),//要显示的字段名(不要加select)
                  new SqlParameter("@Where", Where),//查询条件(注意: 不要加 where)
                  new SqlParameter("@Sort",OrderFieldName + " " + OrderType),//排序索引字段名
                  new SqlParameter("@PageSize",  PageSize),//页码
                  new SqlParameter("@PageIndex", CurPage),//页大小
                  new SqlParameter("@Return", SqlDbType.Int)};//返回记录总数
        parameters[7].Direction = ParameterDirection.Output;
        SqlCommand comm = new SqlCommand("PagedSearch", MyConnection);

        comm.CommandType = CommandType.StoredProcedure;
        comm.Parameters.AddRange(parameters);
        SqlDataAdapter da = new SqlDataAdapter(comm);
        DataTable dt = new DataTable();
        da.Fill(dt);

        RowCount = Convert.ToInt32(parameters[7].Value.ToString()); //返回的总页数
        MyConnection.Close();
        return dt;
    }

    /// <summary>
    /// 分页存储过程
    /// </summary>
    /// <param name="TableName"></param>
    /// <param name="ReturnFields"></param>
    /// <param name="Where"></param>
    /// <param name="OrderFieldName"></param>
    /// <param name="OrderType"></param>
    /// <param name="Groupby"></param>
    /// <param name="PageSize"></param>
    /// <param name="CurPage"></param>
    /// <param name="tempno"></param>
    /// <param name="RowCount"></param>
    /// <returns></returns>
    public DataTable PagingTable(string TableName, string ReturnFields, string Where, string Groupby, string OrderFieldName, string OrderType, int PageSize, int CurPage, string tempno, out int RowCount)
    {
        Open();
        SqlParameter[] parameters = {
                  new SqlParameter("@Table", TableName),//表名
                  new SqlParameter("@TIndex", tempno),//主表KEY
                  new SqlParameter("@Column", ReturnFields),//要显示的字段名(不要加select)
                  new SqlParameter("@Where", Where),//查询条件(注意: 不要加 where)
                  new SqlParameter("@Sort",OrderFieldName + " " + OrderType),//排序索引字段名
                  new SqlParameter("@Group",Groupby),//分组字段名
                  new SqlParameter("@PageSize",  PageSize),//页码
                  new SqlParameter("@PageIndex", CurPage),//页大小
                  new SqlParameter("@Return", SqlDbType.Int)};//返回记录总数
        parameters[8].Direction = ParameterDirection.Output;
        SqlCommand comm = new SqlCommand("PagedSearch2", MyConnection);

        comm.CommandType = CommandType.StoredProcedure;
        comm.Parameters.AddRange(parameters);
        SqlDataAdapter da = new SqlDataAdapter(comm);
        DataTable dt = new DataTable();
        da.Fill(dt);

        RowCount = Convert.ToInt32(parameters[8].Value.ToString()); //返回的总页数
        MyConnection.Close();
        return dt;
    }

    /// <summary>
    /// DataTable转成ArrayList
    /// </summary>
    /// <param name="data"></param>
    /// <returns></returns>
    private static ArrayList DataTable2ArrayList(DataTable data)
    {
        ArrayList array = new ArrayList();
        for (int i = 0; i < data.Rows.Count; i++)
        {
            DataRow row = data.Rows[i];

            Hashtable record = new Hashtable();
            for (int j = 0; j < data.Columns.Count; j++)
            {
                object cellValue = row[j];
                if (cellValue.GetType() == typeof(DBNull))
                {
                    cellValue = null;
                }
                record[data.Columns[j].ColumnName] = cellValue;
            }
            array.Add(record);
        }
        return array;
    }

    /// <summary>
    /// 获取导航栏
    /// </summary>
    /// <param name="acno"></param>
    /// <returns></returns>
    public DataTable GetMenu(string acno)
    {
        Open();
        SqlCommand MyCommand = new SqlCommand();
        MyCommand.Connection = MyConnection;
        MyCommand.CommandText = "select * from menulist where ml_no in(select ap_mlpid from actorpower where ap_acno=@acno) and ml_state=1 union select * from menulist where ml_no in (select ap_mlno from actorpower where ap_acno=@acno) and ml_state=1 ";
        MyCommand.Parameters.Add("@acno", SqlDbType.BigInt).Value = acno;
        DataTable data = new DataTable();
        SqlDataAdapter adapter = new SqlDataAdapter(MyCommand);
        adapter.Fill(data);
        Close();
        return (data);
    }

    /// <summary>
    /// 功能树
    /// </summary>
    /// <returns></returns>
    public DataTable GetMenuTree()
    {
        Open();
        SqlCommand MyCommand = new SqlCommand();
        MyCommand.Connection = MyConnection;
        MyCommand.CommandText = " select * from menulist where ml_state=1 ";
        DataTable data = new DataTable();
        SqlDataAdapter adapter = new SqlDataAdapter(MyCommand);
        adapter.Fill(data);
        Close();
        return (data);
    }

    /// <summary>
    /// 根据角色获取功能树
    /// </summary>
    /// <param name="ac_no"></param>
    /// <returns></returns>
    public DataTable GetMenuTree(string ac_no)
    {
        Open();
        SqlCommand MyCommand = new SqlCommand();
        MyCommand.Connection = MyConnection;
        MyCommand.CommandText = " select *,case when ap_no IS NOT NULL then 'True' end as checked from menulist left join actorpower on ml_no=ap_mlno and ap_acno=@ac_no where ml_state=1 ";
        MyCommand.Parameters.Add("@ac_no", SqlDbType.BigInt).Value = ac_no;
        DataTable data = new DataTable();
        SqlDataAdapter adapter = new SqlDataAdapter(MyCommand);
        adapter.Fill(data);

        Close();
        return (data);
    }

    /// <summary>
    /// 获取用户信息
    /// </summary>
    /// <param name="su_no"></param>
    /// <returns></returns>
    public DataTable GetUserInfor(string su_no)
    {
        Open();
        SqlCommand MyCommand = new SqlCommand();
        MyCommand.Connection = MyConnection;

        MyCommand.CommandText = "select * from systemuser where su_no=@su_no ";
        MyCommand.Parameters.Add("@su_no", SqlDbType.BigInt).Value = su_no;
        DataTable data = new DataTable();
        SqlDataAdapter adapter = new SqlDataAdapter(MyCommand);
        adapter.Fill(data);
        Close();
        return (data);
    }

    /// <summary>
    /// 获取企业信息
    /// </summary>
    /// <param name="cu_no"></param>
    /// <returns></returns>
    public Hashtable GetCompany(string cu_no)
    {
        Open();
        SqlCommand MyCommand = new SqlCommand();
        MyCommand.Connection = MyConnection;

        MyCommand.CommandText = "select * from companyuser left join companylevel on cl_id=cu_kind where cu_no=@cu_no";
        MyCommand.Parameters.Add("@cu_no", SqlDbType.BigInt).Value = cu_no;
        DataTable data = new DataTable();
        SqlDataAdapter adapter = new SqlDataAdapter(MyCommand);
        adapter.Fill(data);
        Close();
        ArrayList da = DataTable2ArrayList(data);
        return da.Count > 0 ? (Hashtable)da[0] : null;
    }

    /// <summary>
    /// 保存企业会员
    /// </summary>
    /// <param name="data"></param>
    /// <returns></returns>
    public int SaveCompany(Hashtable data)
    {
        int res;
        Open();
        SqlCommand MyCommand = MyConnection.CreateCommand();
        SqlTransaction MyTrans;
        MyTrans = MyConnection.BeginTransaction("Tran");
        MyCommand.Connection = MyConnection;
        MyCommand.Transaction = MyTrans;
        try
        {
            MyCommand.Parameters.Add("@cu_user", SqlDbType.NVarChar).Value = data["cu_user"];
            MyCommand.Parameters.Add("@cu_name", SqlDbType.NVarChar).Value = data["cu_name"];
            MyCommand.Parameters.Add("@cu_trade", SqlDbType.NVarChar).Value = data["cu_trade"];
            MyCommand.Parameters.Add("@cu_property", SqlDbType.NVarChar).Value = data["cu_property"];
            MyCommand.Parameters.Add("@cu_license", SqlDbType.NVarChar).Value = data["cu_license"];
            MyCommand.Parameters.Add("@cu_area", SqlDbType.NVarChar).Value = data["cu_area"];
            MyCommand.Parameters.Add("@cu_address", SqlDbType.NVarChar).Value = data["cu_address"];
            MyCommand.Parameters.Add("@cu_contact", SqlDbType.NVarChar).Value = data["cu_contact"];
            MyCommand.Parameters.Add("@cu_industry", SqlDbType.NVarChar).Value = data["cu_industry"];
            MyCommand.Parameters.Add("@cu_category", SqlDbType.NVarChar).Value = data["cu_category"];
            MyCommand.Parameters.Add("@cu_tel", SqlDbType.NVarChar).Value = data["cu_tel"];
            MyCommand.Parameters.Add("@cu_fax", SqlDbType.NVarChar).Value = data["cu_fax"];
            MyCommand.Parameters.Add("@cu_email", SqlDbType.NVarChar).Value = data["cu_email"];
            MyCommand.Parameters.Add("@cu_url", SqlDbType.NVarChar).Value = data["cu_url"];
            MyCommand.Parameters.Add("@cu_introduce", SqlDbType.NText).Value = data["cu_introduce"];
            MyCommand.Parameters.Add("@cu_ok", SqlDbType.Int).Value = "true".Equals(data["cu_ok"]) ? "1" : "0";
            MyCommand.Parameters.Add("@cu_msgname", SqlDbType.NVarChar).Value = data["cu_msgname"];
            MyCommand.Parameters.Add("@cu_msgmobile", SqlDbType.NVarChar).Value = data["cu_msgmobile"];
            MyCommand.Parameters.Add("@user", SqlDbType.NVarChar).Value = data["user"];
            MyCommand.Parameters.Add("@ip", SqlDbType.NVarChar).Value = data["ip"];

            if (string.IsNullOrEmpty(data["cu_no"].ToString()))
            {
                MyCommand.Parameters.Add("@cu_password", SqlDbType.NVarChar).Value = FormsAuthentication.HashPasswordForStoringInConfigFile(data["cu_password"].ToString(), "MD5").ToLower();
                MyCommand.Parameters.Add("@cu_kind", SqlDbType.NVarChar).Value = data["cu_kind"];
                MyCommand.Parameters.Add("@cu_effecttime", SqlDbType.Int).Value = data["cu_effecttime"];
                MyCommand.CommandText = " select count(1) from companyuser where cu_user=@cu_user ";
                int count = Convert.ToInt32(MyCommand.ExecuteScalar());
                if (count == 0)
                {
                    MyCommand.CommandText = " insert into companyuser (cu_user,cu_password,cu_name,cu_trade,cu_property,cu_license,cu_area,cu_contact,cu_tel,cu_fax,cu_email,cu_url,cu_state,cu_apptime,cu_kind,cu_introduce," +
                    "cu_effecttime,cu_address,cu_hide,cu_ok,cu_msgname,cu_msgmobile,cu_industry,cu_category) values (@cu_user,@cu_password,@cu_name,@cu_trade,@cu_property,@cu_license,@cu_area,@cu_contact,@cu_tel,@cu_fax,@cu_email,@cu_url,1,getdate(),@cu_kind,@cu_introduce," +
                    "@cu_effecttime,@cu_address,0,@cu_ok,@cu_msgname,@cu_msgmobile,@cu_industry,@cu_category);select @@Identity";
                    Int64 ret = Convert.ToInt64(MyCommand.ExecuteScalar());
                    if (ret > 0)
                    {
                        WriteLog(data["user"].ToString(), 1, data["ip"].ToString(), "用户【" + data["name"].ToString() + "】，在招聘企业管理功能中进行了数据新增操作，新增记录为【用户：" + data["cu_user"] + "，单位名称：" + data["cu_name"] + "】。", MyCommand);

                        if (data["cu_ismoney"].ToString() == "true")
                        {
                            MyCommand.CommandText = "insert into compayment(cm_cuno,cm_money,cm_inserttime,cm_insertuser,cm_insertip) values(@cu_no,@cm_money,getDate(),@user,@ip)";
                            MyCommand.Parameters.Add("@cu_no", SqlDbType.BigInt).Value = ret;
                            MyCommand.Parameters.Add("@cm_money", SqlDbType.Decimal).Value = data["cm_money"];
                            int b = MyCommand.ExecuteNonQuery();
                            if (b > 0)
                            {
                                MyCommand.Parameters.Clear();
                                WriteLog(data["user"].ToString(), 1, data["ip"].ToString(), "用户【" + data["name"].ToString() + "】，在招聘企业管理功能中进行了进行了缴费新增操作，新增记录为【单位名称：" + data["cu_name"] + "，费用：" + data["cm_money"] + "】。", MyCommand);
                            }
                        }
                        res = 1;
                    }
                    else
                        res = -1;
                }
                else
                    res = 2;
            }
            else
            {
                //MyCommand.CommandText = " select count(1) from companyuser where cu_no<>@cu_no and cu_name=@cu_name ";
                MyCommand.Parameters.Add("@cu_no", SqlDbType.BigInt).Value = data["cu_no"];
                //int count = Convert.ToInt32(MyCommand.ExecuteScalar());
                //if (count == 0)
                //{
                MyCommand.CommandText = " select *,(select di_name from dictionary where di_type=2 and di_code=cu_property) as property1,(select di_name from dictionary where di_type=2 and di_code=@cu_property) as property2,(select di_name from dictionary where di_type=3 and di_code=cu_area) as area1,(select di_name from dictionary where di_type=3 and di_code=@cu_area) as area2,(select di_name from dictionary where di_type=1 and di_code=cu_trade) as trade1,(select di_name from dictionary where di_type=1 and di_code=@cu_trade) as trade2 from companyuser where cu_no=@cu_no ";
                DataTable dt = new DataTable();
                SqlDataAdapter da = new SqlDataAdapter(MyCommand);
                da.Fill(dt);
                if (dt != null && dt.Rows.Count > 0)
                {
                    string memo = "";
                    if (("true".Equals(data["cu_ok"]) && "0".Equals(dt.Rows[0]["cu_ok"].ToString())) || ("false".Equals(data["cu_ok"]) && "1".Equals(dt.Rows[0]["cu_ok"].ToString())))
                    {
                        string ok1 = "免审";
                        if ("0".Equals(dt.Rows[0]["cu_ok"].ToString()))
                            ok1 = "取消免审";
                        string ok2 = "免审";
                        if ("false".Equals(data["cu_ok"]))
                            ok2 = "取消免审";
                        memo = "招聘企业：" + dt.Rows[0]["cu_name"].ToString() + "，将免审从[" + ok1 + "]改为[" + ok2 + "]";
                    }
                    //if (!data["cu_password"].ToString().Equals(dt.Rows[0]["cu_password"].ToString()))
                    //{
                    //    if (string.IsNullOrEmpty(memo))
                    //        memo = "招聘企业：" + dt.Rows[0]["cu_name"].ToString() + "，将密码从[" + dt.Rows[0]["cu_password"].ToString() + "]改为[" + data["cu_password"] + "]";
                    //    else
                    //        memo += "；将密码从[" + dt.Rows[0]["cu_password"].ToString() + "]改为[" + data["cu_password"] + "]";
                    //}
                    if (!data["cu_name"].ToString().Equals(dt.Rows[0]["cu_name"].ToString()))
                    {
                        if (string.IsNullOrEmpty(memo))
                            memo = "招聘企业：" + dt.Rows[0]["cu_name"].ToString() + "，将单位名称从[" + dt.Rows[0]["cu_name"].ToString() + "]改为[" + data["cu_name"] + "]";
                        else
                            memo += "；将单位名称从[" + dt.Rows[0]["cu_name"].ToString() + "]改为[" + data["cu_name"] + "]";
                    }
                    if (!data["cu_license"].ToString().Equals(dt.Rows[0]["cu_license"].ToString()))
                    {
                        if (string.IsNullOrEmpty(memo))
                            memo = "招聘企业：" + dt.Rows[0]["cu_name"].ToString() + "，将营业执照从[" + dt.Rows[0]["cu_license"].ToString() + "]改为[" + data["cu_license"] + "]";
                        else
                            memo += "；将营业执照从[" + dt.Rows[0]["cu_license"].ToString() + "]改为[" + data["cu_license"] + "]";
                    }
                    if (!data["cu_property"].ToString().Equals(dt.Rows[0]["cu_property"].ToString()))
                    {
                        if (string.IsNullOrEmpty(memo))
                            memo = "招聘企业：" + dt.Rows[0]["cu_name"].ToString() + "，将企业性质从[" + dt.Rows[0]["property1"].ToString() + "]改为[" + dt.Rows[0]["property2"].ToString() + "]";
                        else
                            memo += "；将企业性质从[" + dt.Rows[0]["property1"].ToString() + "]改为[" + dt.Rows[0]["property2"].ToString() + "]";
                    }
                    if (!data["cu_area"].ToString().Equals(dt.Rows[0]["cu_area"].ToString()))
                    {
                        if (string.IsNullOrEmpty(memo))
                            memo = "招聘企业：" + dt.Rows[0]["cu_name"].ToString() + "，将所在地区从[" + dt.Rows[0]["area1"].ToString() + "]改为[" + dt.Rows[0]["area2"].ToString() + "]";
                        else
                            memo += "；将所在地区从[" + dt.Rows[0]["area1"].ToString() + "]改为[" + dt.Rows[0]["area2"].ToString() + "]";
                    }
                    if (!data["cu_trade"].ToString().Equals(dt.Rows[0]["cu_trade"].ToString()))
                    {
                        if (string.IsNullOrEmpty(memo))
                            memo = "招聘企业：" + dt.Rows[0]["cu_name"].ToString() + "，将所属行业从[" + dt.Rows[0]["trade1"].ToString() + "]改为[" + dt.Rows[0]["trade2"].ToString() + "]";
                        else
                            memo += "；将所属行业从[" + dt.Rows[0]["trade1"].ToString() + "]改为[" + dt.Rows[0]["trade2"].ToString() + "]";
                    }
                    if (!data["cu_industry"].ToString().Equals(dt.Rows[0]["cu_industry"].ToString()))
                    {
                        if (string.IsNullOrEmpty(memo))
                            memo = "招聘企业：" + dt.Rows[0]["cu_name"].ToString() + "，将所属产业从[" + dt.Rows[0]["cu_industry"].ToString() + "]改为[" + dt.Rows[0]["cu_industry"].ToString() + "]";
                        else
                            memo += "；将所属产业从[" + dt.Rows[0]["cu_industry"].ToString() + "]改为[" + dt.Rows[0]["cu_industry"].ToString() + "]";
                    }
                    if (!data["cu_category"].ToString().Equals(dt.Rows[0]["cu_category"].ToString()))
                    {
                        if (string.IsNullOrEmpty(memo))
                            memo = "招聘企业：" + dt.Rows[0]["cu_name"].ToString() + "，将荣誉称号从[" + dt.Rows[0]["cu_category"].ToString() + "]改为[" + dt.Rows[0]["cu_category"].ToString() + "]";
                        else
                            memo += "；将荣誉称号从[" + dt.Rows[0]["cu_category"].ToString() + "]改为[" + dt.Rows[0]["cu_category"].ToString() + "]";
                    }
                    if (!data["cu_address"].ToString().Equals(dt.Rows[0]["cu_address"].ToString()))
                    {
                        if (string.IsNullOrEmpty(memo))
                            memo = "招聘企业：" + dt.Rows[0]["cu_name"].ToString() + "，将单位地址从[" + dt.Rows[0]["cu_address"].ToString() + "]改为[" + data["cu_address"] + "]";
                        else
                            memo += "；将单位地址从[" + dt.Rows[0]["cu_address"].ToString() + "]改为[" + data["cu_address"] + "]";
                    }
                    if (!data["cu_contact"].ToString().Equals(dt.Rows[0]["cu_contact"].ToString()))
                    {
                        if (string.IsNullOrEmpty(memo))
                            memo = "招聘企业：" + dt.Rows[0]["cu_name"].ToString() + "，将联系人从[" + dt.Rows[0]["cu_contact"].ToString() + "]改为[" + data["cu_contact"] + "]";
                        else
                            memo += "；将联系人从[" + dt.Rows[0]["cu_contact"].ToString() + "]改为[" + data["cu_contact"] + "]";
                    }
                    if (!data["cu_tel"].ToString().Equals(dt.Rows[0]["cu_tel"].ToString()))
                    {
                        if (string.IsNullOrEmpty(memo))
                            memo = "招聘企业：" + dt.Rows[0]["cu_name"].ToString() + "，将联系电话从[" + dt.Rows[0]["cu_tel"].ToString() + "]改为[" + data["cu_tel"] + "]";
                        else
                            memo += "；将联系电话从[" + dt.Rows[0]["cu_tel"].ToString() + "]改为[" + data["cu_tel"] + "]";
                    }
                    if (!data["cu_fax"].ToString().Equals(dt.Rows[0]["cu_fax"].ToString()))
                    {
                        if (string.IsNullOrEmpty(memo))
                            memo = "招聘企业：" + dt.Rows[0]["cu_name"].ToString() + "，将传真从[" + dt.Rows[0]["cu_fax"].ToString() + "]改为[" + data["cu_fax"] + "]";
                        else
                            memo += "；将传真从[" + dt.Rows[0]["cu_fax"].ToString() + "]改为[" + data["cu_fax"] + "]";
                    }
                    if (!data["cu_email"].ToString().Equals(dt.Rows[0]["cu_email"].ToString()))
                    {
                        if (string.IsNullOrEmpty(memo))
                            memo = "招聘企业：" + dt.Rows[0]["cu_name"].ToString() + "，将电子邮箱从[" + dt.Rows[0]["cu_email"].ToString() + "]改为[" + data["cu_email"] + "]";
                        else
                            memo += "；将电子邮箱从[" + dt.Rows[0]["cu_email"].ToString() + "]改为[" + data["cu_email"] + "]";
                    }
                    if (!data["cu_url"].ToString().Equals(dt.Rows[0]["cu_url"].ToString()))
                    {
                        if (string.IsNullOrEmpty(memo))
                            memo = "招聘企业：" + dt.Rows[0]["cu_name"].ToString() + "，将企业网址从[" + dt.Rows[0]["cu_url"].ToString() + "]改为[" + data["cu_url"] + "]";
                        else
                            memo += "；将企业网址从[" + dt.Rows[0]["cu_url"].ToString() + "]改为[" + data["cu_url"] + "]";
                    }
                    if (!data["cu_introduce"].ToString().Equals(dt.Rows[0]["cu_introduce"].ToString()))
                    {
                        if (string.IsNullOrEmpty(memo))
                            memo = "招聘企业：" + dt.Rows[0]["cu_name"].ToString() + "，将企业简介从[" + dt.Rows[0]["cu_introduce"].ToString() + "]改为[" + data["cu_introduce"] + "]";
                        else
                            memo += "；将企业简介从[" + dt.Rows[0]["cu_introduce"].ToString() + "]改为[" + data["cu_introduce"] + "]";
                    }
                    if (!data["cu_msgname"].ToString().Equals(dt.Rows[0]["cu_msgname"].ToString()))
                    {
                        if (string.IsNullOrEmpty(memo))
                            memo = "招聘企业：" + dt.Rows[0]["cu_name"].ToString() + "，将短信联系人从[" + dt.Rows[0]["cu_msgname"].ToString() + "]改为[" + data["cu_msgname"] + "]";
                        else
                            memo += "；将短信联系人从[" + dt.Rows[0]["cu_msgname"].ToString() + "]改为[" + data["cu_msgname"] + "]";
                    }
                    if (!data["cu_msgmobile"].ToString().Equals(dt.Rows[0]["cu_msgmobile"].ToString()))
                    {
                        if (string.IsNullOrEmpty(memo))
                            memo = "招聘企业：" + dt.Rows[0]["cu_name"].ToString() + "，将短信手机从[" + dt.Rows[0]["cu_msgmobile"].ToString() + "]改为[" + data["cu_msgmobile"] + "]";
                        else
                            memo += "；将短信手机从[" + dt.Rows[0]["cu_msgmobile"].ToString() + "]改为[" + data["cu_msgmobile"] + "]";
                    }
                    if (string.IsNullOrEmpty(memo))
                        memo = "招聘企业：" + dt.Rows[0]["cu_name"].ToString() + "，未修改任何字段";
                    MyCommand.CommandText = " update companyuser set cu_name=@cu_name,cu_license=@cu_license,cu_property=@cu_property,cu_area=@cu_area,cu_trade=@cu_trade,cu_address=@cu_address,cu_contact=@cu_contact,cu_tel=@cu_tel,cu_fax=@cu_fax,cu_email=@cu_email,cu_url=@cu_url,cu_introduce=@cu_introduce,cu_ok=@cu_ok,cu_msgname=@cu_msgname,cu_msgmobile=@cu_msgmobile,cu_industry=@cu_industry,cu_category=@cu_category,cu_modifytime=getdate(),cu_modifyip=@ip where cu_no=@cu_no ";
                    res = MyCommand.ExecuteNonQuery();
                    if (res > 0)
                        WriteLog(data["user"].ToString(), 2, data["ip"].ToString(), "用户【" + data["name"].ToString() + "】，在招聘企业管理功能中进行了数据修改操作，修改记录为【" + memo + "】。", MyCommand);
                }
                else
                    res = 0;
                //}
                //else
                //    res = 2;
            }
            MyTrans.Commit();
        }
        catch
        {
            MyTrans.Rollback("Tran");
            res = -1;
        }
        Close();
        return res;
    }

    /// <summary>
    /// 删除企业会员
    /// </summary>
    /// <param name="uid"></param>
    /// <param name="name"></param>
    /// <param name="ip"></param>
    /// <param name="cu_no"></param>
    /// <returns></returns>
    public int DeleteCompany(string uid, string name, string ip, string cu_no)
    {
        int res = 0;
        Open();
        SqlCommand MyCommand = MyConnection.CreateCommand();
        SqlTransaction MyTrans = MyConnection.BeginTransaction("Tran");
        MyCommand.Connection = MyConnection;
        MyCommand.Transaction = MyTrans;
        try
        {
            string[] id = cu_no.Split(',');
            for (int i = 0; i < id.Length; i++)
            {
                MyCommand.CommandText = " select * from companyuser where cu_no=@cu_no ";
                MyCommand.Parameters.Add("@cu_no", SqlDbType.BigInt).Value = id[i];
                DataTable dt = new DataTable();
                SqlDataAdapter da = new SqlDataAdapter(MyCommand);
                da.Fill(dt);
                if (dt != null && dt.Rows.Count > 0)
                {
                    string memo = "招聘企业：" + dt.Rows[0]["cu_name"].ToString();
                    MyCommand.CommandText = "delete from compayment where cm_cuno=@cu_no ";
                    res = MyCommand.ExecuteNonQuery();
                    MyCommand.CommandText = "delete from companyuser where cu_no=@cu_no ";
                    res = MyCommand.ExecuteNonQuery();
                    if (res > 0)
                        WriteLog(uid, 3, ip, "用户【" + name + "】，在招聘企业管理功能中进行了数据删除操作，删除记录为【" + memo + "】。", MyCommand);
                }
                MyCommand.Parameters.Clear();
            }
            MyTrans.Commit();
            res = 1;
        }
        catch (Exception ex)
        {
            MyTrans.Rollback("Tran");
            res = -1;
        }
        Close();
        return res;
    }

    /// <summary>
    /// 批量审核企业会员
    /// </summary>
    /// <param name="uid"></param>
    /// <param name="name"></param>
    /// <param name="ip"></param>
    /// <param name="cu_no"></param>
    /// <param name="cu_state"></param>
    /// <returns></returns>
    public int CheckCompany(string uid, string name, string ip, string cu_no, string cu_state)
    {
        int res = 0;
        Open();
        SqlCommand MyCommand = MyConnection.CreateCommand();
        SqlTransaction MyTrans = MyConnection.BeginTransaction("Tran");
        MyCommand.Connection = MyConnection;
        MyCommand.Transaction = MyTrans;
        try
        {
            string[] id = cu_no.Split(',');
            for (int i = 0; i < id.Length; i++)
            {
                MyCommand.CommandText = " select * from companyuser where cu_no=@cu_no ";
                MyCommand.Parameters.Add("@cu_no", SqlDbType.BigInt).Value = id[i];
                DataTable dt = new DataTable();
                SqlDataAdapter da = new SqlDataAdapter(MyCommand);
                da.Fill(dt);
                if (dt != null && dt.Rows.Count > 0)
                {
                    string memo = "";
                    if (!cu_state.Equals(dt.Rows[0]["cu_state"].ToString()))
                    {
                        string s1 = "未审核";
                        if ("1".Equals(dt.Rows[0]["cu_state"].ToString()))
                            s1 = "审核通过";
                        else if ("2".Equals(dt.Rows[0]["cu_state"].ToString()))
                            s1 = "审核不通过";
                        string s2 = "未审核";
                        if ("1".Equals(cu_state))
                            s2 = "审核通过";
                        else if ("2".Equals(cu_state))
                            s1 = "审核不通过";
                        memo = "招聘企业：" + dt.Rows[0]["cu_name"].ToString() + "，将状态从[" + s1 + "]改为[" + s2 + "]";
                    }
                    if (string.IsNullOrEmpty(memo))
                        memo = "招聘企业：" + dt.Rows[0]["cu_name"].ToString() + "，未修改任何字段";
                    MyCommand.CommandText = "update companyuser set cu_state=@cu_state,cu_modifytime=getdate(),cu_apptime=getdate(),cu_modifyip=@ip where cu_no=@cu_no ";
                    MyCommand.Parameters.Add("@cu_state", SqlDbType.Int).Value = cu_state;
                    MyCommand.Parameters.Add("@ip", SqlDbType.NVarChar).Value = ip;
                    res = MyCommand.ExecuteNonQuery();
                    if (res > 0)
                        WriteLog(uid, 2, ip, "用户【" + name + "】，在招聘企业管理功能中进行了数据修改操作，修改记录为【" + memo + "】。", MyCommand);
                }
                MyCommand.Parameters.Clear();
            }
            MyTrans.Commit();
            res = 1;
        }
        catch (Exception ex)
        {
            MyTrans.Rollback("Tran");
            res = -1;
        }
        Close();
        return res;
    }

    /// <summary>
    /// 显示/隐藏企业会员
    /// </summary>
    /// <param name="uid"></param>
    /// <param name="name"></param>
    /// <param name="ip"></param>
    /// <param name="cu_no"></param>
    /// <param name="cu_hide"></param>
    /// <returns></returns>
    public int LockCompany(string uid, string name, string ip, string cu_no, string cu_hide)
    {
        int res = 0;
        Open();
        SqlCommand MyCommand = MyConnection.CreateCommand();
        SqlTransaction MyTrans = MyConnection.BeginTransaction("Tran");
        MyCommand.Connection = MyConnection;
        MyCommand.Transaction = MyTrans;
        try
        {
            string[] id = cu_no.Split(',');
            for (int i = 0; i < id.Length; i++)
            {
                MyCommand.CommandText = " select * from companyuser where cu_no=@cu_no ";
                MyCommand.Parameters.Add("@cu_no", SqlDbType.BigInt).Value = id[i];
                DataTable dt = new DataTable();
                SqlDataAdapter da = new SqlDataAdapter(MyCommand);
                da.Fill(dt);
                if (dt != null && dt.Rows.Count > 0)
                {
                    string memo = "";
                    if (!cu_hide.Equals(dt.Rows[0]["cu_hide"].ToString()))
                    {
                        string s1 = "隐藏";
                        if (ConfigurationManager.AppSettings["Open"].Equals(dt.Rows[0]["cu_hide"].ToString()))
                            s1 = "显示";
                        string s2 = "隐藏";
                        if (ConfigurationManager.AppSettings["Open"].Equals(cu_hide))
                            s2 = "显示";
                        memo = "招聘企业：" + dt.Rows[0]["cu_name"].ToString() + "，将状态从[" + s1 + "]改为[" + s2 + "]";
                    }
                    if (string.IsNullOrEmpty(memo))
                        memo = "招聘企业：" + dt.Rows[0]["cu_name"].ToString() + "，未修改任何字段";
                    MyCommand.CommandText = "update companyuser set cu_hide=@cu_hide where cu_no=@cu_no ";
                    MyCommand.Parameters.Add("@cu_hide", SqlDbType.Int).Value = cu_hide;
                    res = MyCommand.ExecuteNonQuery();
                    if (res > 0)
                        WriteLog(uid, 2, ip, "用户【" + name + "】，在招聘企业管理功能中进行了数据修改操作，修改记录为【" + memo + "】。", MyCommand);
                }
                MyCommand.Parameters.Clear();
            }
            MyTrans.Commit();
            res = 1;
        }
        catch (Exception ex)
        {
            MyTrans.Rollback("Tran");
            res = -1;
        }
        Close();
        return res;
    }

    /// <summary>
    /// 审核企业会员
    /// </summary>
    /// <param name="data"></param>
    /// <returns></returns>
    public int CheckCompany(Hashtable data)
    {
        int res;
        Open();
        SqlCommand MyCommand = MyConnection.CreateCommand();
        SqlTransaction MyTrans;
        MyTrans = MyConnection.BeginTransaction("Tran");
        MyCommand.Connection = MyConnection;
        MyCommand.Transaction = MyTrans;
        try
        {
            MyCommand.Parameters.Add("@cu_no", SqlDbType.BigInt).Value = data["cu_no"];
            MyCommand.Parameters.Add("@cu_state", SqlDbType.Int).Value = data["cu_state"];
            MyCommand.Parameters.Add("@cu_kind", SqlDbType.NVarChar).Value = data["cu_kind"];
            MyCommand.Parameters.Add("@cu_effecttime", SqlDbType.Int).Value = data["cu_effecttime"];
            MyCommand.Parameters.Add("@user", SqlDbType.NVarChar).Value = data["user"];
            MyCommand.Parameters.Add("@ip", SqlDbType.NVarChar).Value = data["ip"];

            MyCommand.CommandText = " select *,(select cl_name from companylevel where cl_id=@cu_kind) as kind from companyuser left join companylevel on cu_kind=cl_id where cu_no=@cu_no ";
            DataTable dt = new DataTable();
            SqlDataAdapter da = new SqlDataAdapter(MyCommand);
            da.Fill(dt);
            if (dt != null && dt.Rows.Count > 0)
            {
                string memo = "";
                if (!data["cu_state"].ToString().Equals(dt.Rows[0]["cu_state"].ToString()))
                {
                    string s1 = "未审核";
                    if ("1".Equals(dt.Rows[0]["cu_state"].ToString()))
                        s1 = "已审通过";
                    else if ("2".Equals(dt.Rows[0]["cu_state"].ToString()))
                        s1 = "已审未通过";
                    string s2 = "未审核";
                    if ("1".Equals(data["cu_state"].ToString()))
                        s2 = "已审通过";
                    else if ("2".Equals(data["cu_state"].ToString()))
                        s2 = "已审未通过";
                    memo = "招聘企业：" + dt.Rows[0]["cu_name"].ToString() + "，将状态从[" + s1 + "]改为[" + s2 + "]";
                }
                if (!data["cu_kind"].ToString().Equals(dt.Rows[0]["cu_kind"].ToString()))
                {
                    if (string.IsNullOrEmpty(memo))
                        memo = "招聘企业：" + dt.Rows[0]["cu_name"].ToString() + "，将会员类型从[" + dt.Rows[0]["cl_name"].ToString() + "]改为[" + dt.Rows[0]["kind"].ToString() + "]";
                    else
                        memo += "；将会员类型从[" + dt.Rows[0]["cl_name"].ToString() + "]改为[" + dt.Rows[0]["kind"].ToString() + "]";
                }
                if (!data["cu_effecttime"].ToString().Equals(dt.Rows[0]["cu_effecttime"].ToString()))
                {
                    if (string.IsNullOrEmpty(memo))
                        memo = "招聘企业：" + dt.Rows[0]["cu_name"].ToString() + "，将有效期从[" + dt.Rows[0]["cu_effecttime"].ToString() + "]改为[" + data["cu_effecttime"] + "]";
                    else
                        memo += "；将有效期从[" + dt.Rows[0]["cu_effecttime"].ToString() + "]改为[" + data["cu_effecttime"] + "]";
                }
                if (string.IsNullOrEmpty(memo))
                    memo = "招聘企业：" + dt.Rows[0]["cu_name"].ToString() + "，未修改任何字段";
                MyCommand.CommandText = " update companyuser set cu_apptime=getDate(),cu_effecttime=@cu_effecttime,cu_kind=@cu_kind,cu_state=@cu_state,cu_modifytime=getdate(),cu_modifyip=@ip where cu_no=@cu_no ";
                res = MyCommand.ExecuteNonQuery();
                if (res > 0)
                {
                    WriteLog(data["user"].ToString(), 2, data["ip"].ToString(), "用户【" + data["name"].ToString() + "】，在招聘企业管理功能中进行了数据修改操作，修改记录为【" + memo + "】。", MyCommand);
                    MyCommand.CommandText = "insert into compayment(cm_cuno,cm_money,cm_inserttime,cm_insertuser,cm_memo,cm_insertip) values(@cu_no,@cm_money,getDate(),@user,@cm_memo,@ip)";
                    if (data["cu_ismoney"].ToString() == "true")
                    {
                        MyCommand.Parameters.Add("@cm_money", SqlDbType.Decimal).Value = data["cm_money"];
                        MyCommand.Parameters.Add("@cm_memo", SqlDbType.NVarChar).Value = data["cm_memo"];
                    }
                    else
                    {
                        MyCommand.Parameters.Add("@cm_money", SqlDbType.Decimal).Value = 0;
                        MyCommand.Parameters.Add("@cm_memo", SqlDbType.NVarChar).Value = "";
                    }
                    int b = MyCommand.ExecuteNonQuery();
                    if (b > 0)
                    {
                        MyCommand.Parameters.Clear();
                        WriteLog(data["user"].ToString(), 1, data["ip"].ToString(), "用户【" + data["name"].ToString() + "】，在招聘企业管理功能中进行了进行了缴费新增操作，新增记录为【单位名称：" + data["cu_name"] + "，费用：" + data["cm_money"] + "】。", MyCommand);
                    }
                }
            }
            else
                res = 0;

            MyTrans.Commit();
        }
        catch
        {
            MyTrans.Rollback("Tran");
            res = -1;
        }
        Close();
        return res;
    }

    /// <summary>
    /// 免审/取消企业会员
    /// </summary>
    /// <param name="uid"></param>
    /// <param name="name"></param>
    /// <param name="ip"></param>
    /// <param name="cu_no"></param>
    /// <param name="cu_ok"></param>
    /// <returns></returns>
    public int OkCompany(string uid, string name, string ip, string cu_no, string cu_ok)
    {
        int res = 0;
        Open();
        SqlCommand MyCommand = MyConnection.CreateCommand();
        SqlTransaction MyTrans = MyConnection.BeginTransaction("Tran");
        MyCommand.Connection = MyConnection;
        MyCommand.Transaction = MyTrans;
        try
        {
            string[] id = cu_no.Split(',');
            for (int i = 0; i < id.Length; i++)
            {
                MyCommand.CommandText = " select * from companyuser where cu_no=@cu_no ";
                MyCommand.Parameters.Add("@cu_no", SqlDbType.BigInt).Value = id[i];
                DataTable dt = new DataTable();
                SqlDataAdapter da = new SqlDataAdapter(MyCommand);
                da.Fill(dt);
                if (dt != null && dt.Rows.Count > 0)
                {
                    string memo = "";
                    if (!cu_ok.Equals(dt.Rows[0]["cu_ok"].ToString()))
                    {
                        string ok1 = "免审";
                        if ("0".Equals(dt.Rows[0]["cu_ok"].ToString()))
                            ok1 = "取消免审";
                        string ok2 = "免审";
                        if ("0".Equals(cu_ok))
                            ok2 = "取消免审";
                        memo = "招聘企业：" + dt.Rows[0]["cu_name"].ToString() + "，将免审从[" + ok1 + "]改为[" + ok2 + "]";
                    }
                    if (string.IsNullOrEmpty(memo))
                        memo = "招聘企业：" + dt.Rows[0]["cu_name"].ToString() + "，未修改任何字段";
                    MyCommand.CommandText = "update companyuser set cu_ok=@cu_ok where cu_no=@cu_no ";
                    MyCommand.Parameters.Add("@cu_ok", SqlDbType.Int).Value = cu_ok;
                    res = MyCommand.ExecuteNonQuery();
                    if (res > 0)
                        WriteLog(uid, 2, ip, "用户【" + name + "】，在招聘企业管理功能中进行了数据修改操作，修改记录为【" + memo + "】。", MyCommand);
                }
                MyCommand.Parameters.Clear();
            }
            MyTrans.Commit();
            res = 1;
        }
        catch (Exception ex)
        {
            MyTrans.Rollback("Tran");
            res = -1;
        }
        Close();
        return res;
    }

    /// <summary>
    /// 企业描色
    /// </summary>
    /// <param name="uid"></param>
    /// <param name="name"></param>
    /// <param name="ip"></param>
    /// <param name="cu_no"></param>
    /// <param name="cu_color"></param>
    /// <returns></returns>
    public int SaveCompanyColor(string uid, string name, string ip, string cu_no, string cu_color)
    {
        int res = 0;
        Open();
        SqlCommand MyCommand = MyConnection.CreateCommand();
        SqlTransaction MyTrans = MyConnection.BeginTransaction("Tran");
        MyCommand.Connection = MyConnection;
        MyCommand.Transaction = MyTrans;
        try
        {
            string[] id = cu_no.Split(',');
            for (int i = 0; i < id.Length; i++)
            {
                MyCommand.CommandText = " select * from companyuser where cu_no=@cu_no ";
                MyCommand.Parameters.Add("@cu_no", SqlDbType.BigInt).Value = id[i];
                DataTable dt = new DataTable();
                SqlDataAdapter da = new SqlDataAdapter(MyCommand);
                da.Fill(dt);
                if (dt != null && dt.Rows.Count > 0)
                {
                    string memo = "";
                    if (!cu_color.Equals(dt.Rows[0]["cu_color"].ToString()))
                        memo = "招聘企业：" + dt.Rows[0]["cu_name"].ToString() + "，将颜色从[" + dt.Rows[0]["cu_color"].ToString() + "]改为[" + cu_color + "]";
                    if (string.IsNullOrEmpty(memo))
                        memo = "招聘企业：" + dt.Rows[0]["cu_name"].ToString() + "，未修改任何字段";
                    MyCommand.CommandText = "update companyuser set cu_color=@cu_color where cu_no=@cu_no ";
                    MyCommand.Parameters.Add("@cu_color", SqlDbType.NVarChar).Value = cu_color;
                    res = MyCommand.ExecuteNonQuery();
                    if (res > 0)
                        WriteLog(uid, 2, ip, "用户【" + name + "】，在招聘企业管理功能中进行了数据修改操作，修改记录为【" + memo + "】。", MyCommand);
                }
                MyCommand.Parameters.Clear();
            }
            MyTrans.Commit();
            res = 1;
        }
        catch (Exception ex)
        {
            MyTrans.Rollback("Tran");
            res = -1;
        }
        Close();
        return res;
    }

    /// <summary>
    /// 获取企业名称
    /// </summary>
    /// <param name="cu_no"></param>
    /// <returns></returns>
    public string GetCompanyName(string cu_no)
    {
        string res = "";
        Open();
        try
        {
            SqlCommand MyCommand = new SqlCommand("select cu_name from companyuser where cu_no=@cu_no", MyConnection);
            MyCommand.Parameters.Add("@cu_no", SqlDbType.BigInt).Value = cu_no;
            res = MyCommand.ExecuteScalar().ToString();
        }
        catch (Exception e)
        {

        }
        Close();
        return res;
    }

    /// <summary>
    /// 获取招聘职位
    /// </summary>
    /// <param name="re_no"></param>
    /// <returns></returns>
    public Hashtable GetRecruit(string re_no)
    {
        Open();
        SqlCommand MyCommand = new SqlCommand();
        MyCommand.Connection = MyConnection;

        MyCommand.CommandText = "select * from recruit where re_no =@re_no";
        MyCommand.Parameters.Add("@re_no", SqlDbType.BigInt).Value = re_no;
        DataTable data = new DataTable();
        SqlDataAdapter adapter = new SqlDataAdapter(MyCommand);
        adapter.Fill(data);
        Close();
        ArrayList da = DataTable2ArrayList(data);
        return da.Count > 0 ? (Hashtable)da[0] : null;
    }

    /// <summary>
    /// 保存招聘职位
    /// </summary>
    /// <param name="data"></param>
    /// <returns></returns>
    public int SaveRecruit(Hashtable data)
    {
        int res;
        Open();
        SqlCommand MyCommand = MyConnection.CreateCommand();
        SqlTransaction MyTrans;
        MyTrans = MyConnection.BeginTransaction("Tran");
        MyCommand.Connection = MyConnection;
        MyCommand.Transaction = MyTrans;
        try
        {
            MyCommand.Parameters.Add("@re_cuno", SqlDbType.BigInt).Value = data["re_cuno"];
            MyCommand.Parameters.Add("@re_name", SqlDbType.NVarChar).Value = data["re_name"];
            MyCommand.Parameters.Add("@re_need", SqlDbType.Int).Value = data["re_need"].ToString() == "true" ? "1" : "0";
            MyCommand.Parameters.Add("@re_num", SqlDbType.Int).Value = data["re_num"];
            MyCommand.Parameters.Add("@re_sex", SqlDbType.NVarChar).Value = data["re_sex"];
            MyCommand.Parameters.Add("@re_kind", SqlDbType.NVarChar).Value = data["re_kind"];
            MyCommand.Parameters.Add("@re_edu", SqlDbType.NVarChar).Value = data["re_edu"];
            MyCommand.Parameters.Add("@re_edu2", SqlDbType.NVarChar).Value = data["re_edu2"].ToString() == "true" ? "以上" : "";
            MyCommand.Parameters.Add("@re_target", SqlDbType.NVarChar).Value = data["re_target"];
            MyCommand.Parameters.Add("@re_jobtype1", SqlDbType.NVarChar).Value = data["re_jobtype1"];
            MyCommand.Parameters.Add("@re_jobtype2", SqlDbType.NVarChar).Value = data["re_jobtype2"];
            MyCommand.Parameters.Add("@re_jobtype11", SqlDbType.NVarChar).Value = data["re_jobtype11"];
            MyCommand.Parameters.Add("@re_jobtype22", SqlDbType.NVarChar).Value = data["re_jobtype22"];
            MyCommand.Parameters.Add("@re_age", SqlDbType.NVarChar).Value = data["re_age"];
            MyCommand.Parameters.Add("@re_pay1", SqlDbType.NVarChar).Value = data["re_pay1"];
            MyCommand.Parameters.Add("@re_pay2", SqlDbType.NVarChar).Value = data["re_pay2"];
            MyCommand.Parameters.Add("@re_area", SqlDbType.NVarChar).Value = data["re_area"];
            MyCommand.Parameters.Add("@re_memo", SqlDbType.NText).Value = data["re_memo"];
            MyCommand.Parameters.Add("@re_effecttime", SqlDbType.Int).Value = data["re_effecttime"];
            MyCommand.Parameters.Add("@user", SqlDbType.NVarChar).Value = data["user"];
            MyCommand.Parameters.Add("@ip", SqlDbType.NVarChar).Value = data["ip"];

            if (string.IsNullOrEmpty(data["re_no"].ToString()))
            {
                MyCommand.CommandText = "insert into recruit (re_cuno,re_name,re_num,re_sex,re_kind,re_edu,re_edu2,re_target,re_jobtype1,re_jobtype11,re_jobtype2,re_jobtype22,re_age,re_pay1,re_pay2,re_area,re_effecttime,re_memo," +
                    "re_inserttime,re_insertip,re_hits,re_resumenum,re_hide,re_delete,re_state,re_orderid,re_need,re_needstate) values (@re_cuno,@re_name,@re_num,@re_sex,@re_kind,@re_edu,@re_edu2,@re_target,@re_jobtype1,@re_jobtype11,@re_jobtype2,@re_jobtype22,@re_age,@re_pay1,@re_pay2,@re_area,@re_effecttime,@re_memo,getDate(),@ip,0,0,0,0,1,0,@re_need,0) ";
                res = MyCommand.ExecuteNonQuery();
                if (res > 0)
                    WriteLog(data["user"].ToString(), 1, data["ip"].ToString(), "用户【" + data["name"].ToString() + "】，在招聘职位管理功能中进行了招聘职位新增操作，新增记录为【企业名称：" + data["cu_name"] + "，招聘职位：" + data["re_name"] + "】。", MyCommand);
                else
                    res = -1;
            }
            else
            {
                MyCommand.CommandText = " select *,(select di_name from dictionary where di_type=5 and di_code=re_sex) as sex1,(select di_name from dictionary where di_type=5 and di_code=@re_sex) as sex2,(select di_name from dictionary where di_type=6 and di_code=re_kind) as kind1,(select di_name from dictionary where di_type=6 and di_code=@re_kind) as kind2,(select di_name from dictionary where di_type=4 and di_code=re_edu) as edu1,(select di_name from dictionary where di_type=4 and di_code=@re_edu) as edu2," +
                    "(select di_name from dictionary where di_type=7 and di_code=re_target) as target1,(select di_name from dictionary where di_type=7 and di_code=@re_target) as target2,(select jt_name from jobtype where jt_id=re_jobtype1) as jobtype11,(select jt_name from jobtype where jt_id=@re_jobtype1) as jobtype12,(select jt_name from jobtype where jt_id=re_jobtype2) as jobtype21,(select jt_name from jobtype where jt_id=@re_jobtype2) as jobtype22,(select di_name from dictionary where di_type=3 and di_code=re_area) as area1," +
                    "(select di_name from dictionary where di_type=3 and di_code=@re_area) as area2,(select jt_name from jobtype where jt_id=re_jobtype11) as jobtype31,(select jt_name from jobtype where jt_id=@re_jobtype11) as jobtype32,(select jt_name from jobtype where jt_id=re_jobtype22) as jobtype41,(select jt_name from jobtype where jt_id=@re_jobtype22) as jobtype42 from recruit where re_no=@re_no ";
                MyCommand.Parameters.Add("@re_no", SqlDbType.BigInt).Value = data["re_no"];
                DataTable dt = new DataTable();
                SqlDataAdapter da = new SqlDataAdapter(MyCommand);
                da.Fill(dt);
                if (dt != null && dt.Rows.Count > 0)
                {
                    string memo = "";
                    if (!data["re_name"].ToString().Equals(dt.Rows[0]["re_name"].ToString()))
                        memo = "招聘职位：" + dt.Rows[0]["re_name"].ToString() + "，将岗位名称从[" + dt.Rows[0]["re_name"].ToString() + "]改为[" + data["re_name"] + "]";
                    if (("true".Equals(data["re_need"]) && "0".Equals(dt.Rows[0]["re_need"].ToString())) || ("false".Equals(data["re_need"]) && "1".Equals(dt.Rows[0]["re_need"].ToString())))
                    {
                        string s1 = "紧缺";
                        if ("0".Equals(dt.Rows[0]["re_need"].ToString()))
                            s1 = "不紧缺";
                        string s2 = "紧缺";
                        if (("false".Equals(data["re_need"])))
                            s2 = "不紧缺";
                        if (string.IsNullOrEmpty(memo))
                            memo = "招聘职位：" + dt.Rows[0]["re_name"].ToString() + "，将紧缺状态从[" + s1 + "]改为[" + s2 + "]";
                        else
                            memo += "；将紧缺状态从[" + s1 + "]改为[" + s2 + "]";
                    }
                    if (!data["re_num"].ToString().Equals(dt.Rows[0]["re_num"].ToString()))
                    {
                        if (string.IsNullOrEmpty(memo))
                            memo = "招聘职位：" + dt.Rows[0]["re_name"].ToString() + "，将招聘人数从[" + dt.Rows[0]["re_num"].ToString() + "]改为[" + data["re_num"] + "]";
                        else
                            memo += "；将招聘人数从[" + dt.Rows[0]["re_num"].ToString() + "]改为[" + data["re_num"] + "]";
                    }
                    if (!data["re_sex"].ToString().Equals(dt.Rows[0]["re_sex"].ToString()))
                    {
                        if (string.IsNullOrEmpty(memo))
                            memo = "招聘职位：" + dt.Rows[0]["re_name"].ToString() + "，将性别从[" + dt.Rows[0]["sex1"].ToString() + "]改为[" + dt.Rows[0]["sex2"].ToString() + "]";
                        else
                            memo += "；将性别从[" + dt.Rows[0]["sex1"].ToString() + "]改为[" + dt.Rows[0]["sex2"].ToString() + "]";
                    }
                    if (!data["re_kind"].ToString().Equals(dt.Rows[0]["re_kind"].ToString()))
                    {
                        if (string.IsNullOrEmpty(memo))
                            memo = "招聘职位：" + dt.Rows[0]["re_name"].ToString() + "，将工作性质从[" + dt.Rows[0]["kind1"].ToString() + "]改为[" + dt.Rows[0]["kind2"].ToString() + "]";
                        else
                            memo += "；将工作性质从[" + dt.Rows[0]["kind1"].ToString() + "]改为[" + dt.Rows[0]["kind2"].ToString() + "]";
                    }
                    if (!data["re_edu"].ToString().Equals(dt.Rows[0]["re_edu"].ToString()))
                    {
                        if (string.IsNullOrEmpty(memo))
                            memo = "招聘职位：" + dt.Rows[0]["re_name"].ToString() + "，将学历从[" + dt.Rows[0]["edu1"].ToString() + "]改为[" + dt.Rows[0]["edu2"].ToString() + "]";
                        else
                            memo += "；将学历从[" + dt.Rows[0]["edu1"].ToString() + "]改为[" + dt.Rows[0]["edu2"].ToString() + "]";
                    }
                    if (("true".Equals(data["re_edu2"]) && string.IsNullOrEmpty(dt.Rows[0]["re_edu2"].ToString())) || ("false".Equals(data["re_edu2"]) && !string.IsNullOrEmpty(dt.Rows[0]["re_edu2"].ToString())))
                    {
                        string s1 = "以上";
                        if ("".Equals(dt.Rows[0]["re_edu2"].ToString()))
                            s1 = "";
                        string s2 = "以上";
                        if (("false".Equals(data["re_edu2"])))
                            s2 = "";
                        if (string.IsNullOrEmpty(memo))
                            memo = "招聘职位：" + dt.Rows[0]["re_name"].ToString() + "，将学历2从[" + s1 + "]改为[" + s2 + "]";
                        else
                            memo += "；将学历2从[" + s1 + "]改为[" + s2 + "]";
                    }
                    if (!data["re_target"].ToString().Equals(dt.Rows[0]["re_target"].ToString()))
                    {
                        if (string.IsNullOrEmpty(memo))
                            memo = "招聘职位：" + dt.Rows[0]["re_name"].ToString() + "，将招聘对象从[" + dt.Rows[0]["target1"].ToString() + "]改为[" + dt.Rows[0]["target2"].ToString() + "]";
                        else
                            memo += "；将招聘对象从[" + dt.Rows[0]["target1"].ToString() + "]改为[" + dt.Rows[0]["target2"].ToString() + "]";
                    }
                    if (!data["re_jobtype1"].ToString().Equals(dt.Rows[0]["re_jobtype1"].ToString()))
                    {
                        if (string.IsNullOrEmpty(memo))
                            memo = "招聘职位：" + dt.Rows[0]["re_name"].ToString() + "，将岗位类别1从[" + dt.Rows[0]["jobtype11"].ToString() + "]改为[" + dt.Rows[0]["jobtype12"].ToString() + "]";
                        else
                            memo += "；将岗位类别1从[" + dt.Rows[0]["jobtype11"].ToString() + "]改为[" + dt.Rows[0]["jobtype12"].ToString() + "]";
                    }
                    if (!data["re_jobtype11"].ToString().Equals(dt.Rows[0]["re_jobtype11"].ToString()))
                    {
                        if (string.IsNullOrEmpty(memo))
                            memo = "招聘职位：" + dt.Rows[0]["re_name"].ToString() + "，将岗位类别11从[" + dt.Rows[0]["jobtype31"].ToString() + "]改为[" + dt.Rows[0]["jobtype32"].ToString() + "]";
                        else
                            memo += "；将岗位类别11从[" + dt.Rows[0]["jobtype31"].ToString() + "]改为[" + dt.Rows[0]["jobtype32"].ToString() + "]";
                    }
                    if (!data["re_jobtype2"].ToString().Equals(dt.Rows[0]["re_jobtype2"].ToString()))
                    {
                        if (string.IsNullOrEmpty(memo))
                            memo = "招聘职位：" + dt.Rows[0]["re_name"].ToString() + "，将岗位类别2从[" + dt.Rows[0]["jobtype21"].ToString() + "]改为[" + dt.Rows[0]["jobtype22"].ToString() + "]";
                        else
                            memo += "；将岗位类别2从[" + dt.Rows[0]["jobtype21"].ToString() + "]改为[" + dt.Rows[0]["jobtype22"].ToString() + "]";
                    }
                    if (!data["re_jobtype22"].ToString().Equals(dt.Rows[0]["re_jobtype22"].ToString()))
                    {
                        if (string.IsNullOrEmpty(memo))
                            memo = "招聘职位：" + dt.Rows[0]["re_name"].ToString() + "，将岗位类别22从[" + dt.Rows[0]["jobtype41"].ToString() + "]改为[" + dt.Rows[0]["jobtype42"].ToString() + "]";
                        else
                            memo += "；将岗位类别22从[" + dt.Rows[0]["jobtype41"].ToString() + "]改为[" + dt.Rows[0]["jobtype42"].ToString() + "]";
                    }
                    if (!data["re_age"].ToString().Equals(dt.Rows[0]["re_age"].ToString()))
                    {
                        if (string.IsNullOrEmpty(memo))
                            memo = "招聘职位：" + dt.Rows[0]["re_name"].ToString() + "，将年龄从[" + dt.Rows[0]["re_age"].ToString() + "]改为[" + data["re_age"] + "]";
                        else
                            memo += "；将年龄从[" + dt.Rows[0]["re_age"].ToString() + "]改为[" + data["re_age"] + "]";
                    }
                    if (!data["re_pay1"].ToString().Equals(dt.Rows[0]["re_pay1"].ToString()))
                    {
                        if (string.IsNullOrEmpty(memo))
                            memo = "招聘职位：" + dt.Rows[0]["re_name"].ToString() + "，将待遇1从[" + dt.Rows[0]["re_pay1"].ToString() + "]改为[" + data["re_pay1"] + "]";
                        else
                            memo += "；将待遇1从[" + dt.Rows[0]["re_pay1"].ToString() + "]改为[" + data["re_pay1"] + "]";
                    }
                    if (!data["re_pay2"].ToString().Equals(dt.Rows[0]["re_pay2"].ToString()))
                    {
                        if (string.IsNullOrEmpty(memo))
                            memo = "招聘职位：" + dt.Rows[0]["re_name"].ToString() + "，将待遇2从[" + dt.Rows[0]["re_pay2"].ToString() + "]改为[" + data["re_pay2"] + "]";
                        else
                            memo += "；将待遇2从[" + dt.Rows[0]["re_pay2"].ToString() + "]改为[" + data["re_pay2"] + "]";
                    }
                    if (!data["re_area"].ToString().Equals(dt.Rows[0]["re_area"].ToString()))
                    {
                        if (string.IsNullOrEmpty(memo))
                            memo = "招聘职位：" + dt.Rows[0]["re_name"].ToString() + "，将工作地区从[" + dt.Rows[0]["area1"].ToString() + "]改为[" + dt.Rows[0]["area2"].ToString() + "]";
                        else
                            memo += "；将工作地区从[" + dt.Rows[0]["area1"].ToString() + "]改为[" + dt.Rows[0]["area2"].ToString() + "]";
                    }
                    if (!data["re_effecttime"].ToString().Equals(dt.Rows[0]["re_effecttime"].ToString()))
                    {
                        if (string.IsNullOrEmpty(memo))
                            memo = "招聘职位：" + dt.Rows[0]["re_name"].ToString() + "，将有效期从[" + dt.Rows[0]["re_effecttime"].ToString() + "]改为[" + data["re_effecttime"] + "]";
                        else
                            memo += "；将有效期从[" + dt.Rows[0]["re_effecttime"].ToString() + "]改为[" + data["re_effecttime"] + "]";
                    }
                    if (!data["re_memo"].ToString().Equals(dt.Rows[0]["re_memo"].ToString()))
                    {
                        if (string.IsNullOrEmpty(memo))
                            memo = "招聘职位：" + dt.Rows[0]["re_name"].ToString() + "，将其他要求从[" + dt.Rows[0]["re_memo"].ToString() + "]改为[" + data["re_memo"] + "]";
                        else
                            memo += "；将其他要求从[" + dt.Rows[0]["re_memo"].ToString() + "]改为[" + data["re_memo"] + "]";
                    }
                    if (string.IsNullOrEmpty(memo))
                        memo = "招聘职位：" + dt.Rows[0]["re_name"].ToString() + "，未修改任何字段";
                    MyCommand.CommandText = " update recruit set re_name=@re_name,re_need=@re_need,re_num=@re_num,re_sex=@re_sex,re_kind=@re_kind,re_edu=@re_edu,re_edu2=@re_edu2,re_target=@re_target,re_jobtype1=@re_jobtype1,re_jobtype11=@re_jobtype11,re_jobtype2=@re_jobtype2,re_jobtype22=@re_jobtype22,re_age=@re_age,re_pay1=@re_pay1,re_pay2=@re_pay2,re_area=@re_area,re_effecttime=@re_effecttime,re_memo=@re_memo where re_no=@re_no ";
                    res = MyCommand.ExecuteNonQuery();
                    if (res > 0)
                        WriteLog(data["user"].ToString(), 2, data["ip"].ToString(), "用户【" + data["name"].ToString() + "】，在招聘职位管理功能中进行了招聘职位修改操作，修改记录为【" + memo + "】。", MyCommand);
                }
                else
                    res = 0;
            }
            MyTrans.Commit();
        }
        catch
        {
            MyTrans.Rollback("Tran");
            res = -1;
        }
        Close();
        return res;
    }

    /// <summary>
    /// 删除招聘职位
    /// </summary>
    /// <param name="uid"></param>
    /// <param name="name"></param>
    /// <param name="ip"></param>
    /// <param name="re_no"></param>
    /// <returns></returns>
    public int DeleteRecruit(string uid, string name, string ip, string re_no)
    {
        int res = 0;
        Open();
        SqlCommand MyCommand = MyConnection.CreateCommand();
        SqlTransaction MyTrans = MyConnection.BeginTransaction("Tran");
        MyCommand.Connection = MyConnection;
        MyCommand.Transaction = MyTrans;
        try
        {
            string[] id = re_no.Split(',');
            for (int i = 0; i < id.Length; i++)
            {
                MyCommand.CommandText = " select * from recruit where re_no=@re_no ";
                MyCommand.Parameters.Add("@re_no", SqlDbType.BigInt).Value = id[i];
                DataTable dt = new DataTable();
                SqlDataAdapter da = new SqlDataAdapter(MyCommand);
                da.Fill(dt);
                if (dt != null && dt.Rows.Count > 0)
                {
                    string memo = "招聘职位：" + dt.Rows[0]["re_name"].ToString();
                    MyCommand.CommandText = "delete from recruit where re_no=@re_no ";
                    res = MyCommand.ExecuteNonQuery();
                    if (res > 0)
                        WriteLog(uid, 3, ip, "用户【" + name + "】，在招聘职位管理功能中进行了招聘职位删除操作，删除记录为【" + memo + "】。", MyCommand);
                }
                MyCommand.Parameters.Clear();
            }
            MyTrans.Commit();
            res = 1;
        }
        catch (Exception ex)
        {
            MyTrans.Rollback("Tran");
            res = -1;
        }
        Close();
        return res;
    }

    /// <summary>
    /// 审核招聘职位
    /// </summary>
    /// <param name="uid"></param>
    /// <param name="name"></param>
    /// <param name="ip"></param>
    /// <param name="re_no"></param>
    /// <param name="re_state"></param>
    /// <returns></returns>
    public int CheckRecruit(string uid, string name, string ip, string re_no, string re_state)
    {
        int res = 0;
        Open();
        SqlCommand MyCommand = MyConnection.CreateCommand();
        SqlTransaction MyTrans = MyConnection.BeginTransaction("Tran");
        MyCommand.Connection = MyConnection;
        MyCommand.Transaction = MyTrans;
        try
        {
            string[] id = re_no.Split(',');
            for (int i = 0; i < id.Length; i++)
            {
                MyCommand.CommandText = " select * from recruit where re_no=@re_no ";
                MyCommand.Parameters.Add("@re_no", SqlDbType.BigInt).Value = id[i];
                DataTable dt = new DataTable();
                SqlDataAdapter da = new SqlDataAdapter(MyCommand);
                da.Fill(dt);
                if (dt != null && dt.Rows.Count > 0)
                {
                    string memo = "";
                    if (!re_state.Equals(dt.Rows[0]["re_state"].ToString()))
                    {
                        string s1 = "未审核";
                        if ("1".Equals(dt.Rows[0]["re_state"].ToString()))
                            s1 = "审核通过";
                        else if ("2".Equals(dt.Rows[0]["re_state"].ToString()))
                            s1 = "审核未通过";
                        string s2 = "未审核";
                        if ("1".Equals(re_state))
                            s2 = "审核通过";
                        else if ("2".Equals(re_state))
                            s2 = "审核未通过";
                        memo = "招聘岗位：" + dt.Rows[0]["re_name"].ToString() + "，将状态从[" + s1 + "]改为[" + s2 + "]";
                    }
                    if (string.IsNullOrEmpty(memo))
                        memo = "招聘岗位：" + dt.Rows[0]["re_name"].ToString() + "，未修改任何字段";
                    MyCommand.CommandText = "update recruit set re_state=@re_state where re_no=@re_no ";
                    MyCommand.Parameters.Add("@re_state", SqlDbType.Int).Value = re_state;
                    res = MyCommand.ExecuteNonQuery();
                    if (res > 0)
                        WriteLog(uid, 2, ip, "用户【" + name + "】，在招聘管理功能中进行了数据修改操作，修改记录为【" + memo + "】。", MyCommand);
                }
                MyCommand.Parameters.Clear();
            }
            MyTrans.Commit();
            res = 1;
        }
        catch (Exception ex)
        {
            MyTrans.Rollback("Tran");
            res = -1;
        }
        Close();
        return res;
    }

    /// <summary>
    /// 隐藏/显示招聘职位
    /// </summary>
    /// <param name="uid"></param>
    /// <param name="name"></param>
    /// <param name="ip"></param>
    /// <param name="re_no"></param>
    /// <param name="re_hide"></param>
    /// <returns></returns>
    public int LockRecruit(string uid, string name, string ip, string re_no, string re_hide)
    {
        int res = 0;
        Open();
        SqlCommand MyCommand = MyConnection.CreateCommand();
        SqlTransaction MyTrans = MyConnection.BeginTransaction("Tran");
        MyCommand.Connection = MyConnection;
        MyCommand.Transaction = MyTrans;
        try
        {
            string[] id = re_no.Split(',');
            for (int i = 0; i < id.Length; i++)
            {
                MyCommand.CommandText = " select * from recruit where re_no=@re_no ";
                MyCommand.Parameters.Add("@re_no", SqlDbType.BigInt).Value = id[i];
                DataTable dt = new DataTable();
                SqlDataAdapter da = new SqlDataAdapter(MyCommand);
                da.Fill(dt);
                if (dt != null && dt.Rows.Count > 0)
                {
                    string memo = "";
                    if (!re_hide.Equals(dt.Rows[0]["re_hide"].ToString()))
                    {
                        string s1 = "隐藏";
                        if (ConfigurationManager.AppSettings["Open"].Equals(dt.Rows[0]["re_hide"].ToString()))
                            s1 = "显示";
                        string s2 = "隐藏";
                        if (ConfigurationManager.AppSettings["Open"].Equals(re_hide))
                            s2 = "显示";
                        memo = "招聘职位：" + dt.Rows[0]["re_name"].ToString() + "，将状态从[" + s1 + "]改为[" + s2 + "]";
                    }
                    if (string.IsNullOrEmpty(memo))
                        memo = "招聘职位：" + dt.Rows[0]["re_name"].ToString() + "，未修改任何字段";
                    MyCommand.CommandText = "update recruit set re_hide=@re_hide where re_no=@re_no ";
                    MyCommand.Parameters.Add("@re_hide", SqlDbType.Int).Value = re_hide;
                    res = MyCommand.ExecuteNonQuery();
                    if (res > 0)
                        WriteLog(uid, 2, ip, "用户【" + name + "】，在招聘职位管理功能中进行了招聘职位修改操作，修改记录为【" + memo + "】。", MyCommand);
                }
                MyCommand.Parameters.Clear();
            }
            MyTrans.Commit();
            res = 1;
        }
        catch (Exception ex)
        {
            MyTrans.Rollback("Tran");
            res = -1;
        }
        Close();
        return res;
    }

    /// <summary>
    /// 归零招聘职位点击率
    /// </summary>
    /// <param name="uid"></param>
    /// <param name="name"></param>
    /// <param name="ip"></param>
    /// <param name="re_no"></param>
    /// <returns></returns>
    public int ZeroRecruit(string uid, string name, string ip, string re_no)
    {
        int res = 0;
        Open();
        SqlCommand MyCommand = MyConnection.CreateCommand();
        SqlTransaction MyTrans = MyConnection.BeginTransaction("Tran");
        MyCommand.Connection = MyConnection;
        MyCommand.Transaction = MyTrans;
        try
        {
            string[] id = re_no.Split(',');
            for (int i = 0; i < id.Length; i++)
            {
                MyCommand.CommandText = " select * from recruit where re_no=@re_no ";
                MyCommand.Parameters.Add("@re_no", SqlDbType.BigInt).Value = id[i];
                DataTable dt = new DataTable();
                SqlDataAdapter da = new SqlDataAdapter(MyCommand);
                da.Fill(dt);
                if (dt != null && dt.Rows.Count > 0)
                {
                    string memo = "";
                    if (string.IsNullOrEmpty(memo))
                        memo = "招聘职位：" + dt.Rows[0]["re_name"].ToString() + "，将点击率归零";
                    MyCommand.CommandText = "update recruit set re_hits=0 where re_no=@re_no ";
                    res = MyCommand.ExecuteNonQuery();
                    if (res > 0)
                        WriteLog(uid, 2, ip, "用户【" + name + "】，在招聘职位管理功能中进行了招聘职位修改操作，修改记录为【" + memo + "】。", MyCommand);
                }
                MyCommand.Parameters.Clear();
            }
            MyTrans.Commit();
            res = 1;
        }
        catch (Exception ex)
        {
            MyTrans.Rollback("Tran");
            res = -1;
        }
        Close();
        return res;
    }

    /// <summary>
    /// 刷新招聘职位
    /// </summary>
    /// <param name="uid"></param>
    /// <param name="name"></param>
    /// <param name="ip"></param>
    /// <param name="re_no"></param>
    /// <returns></returns>
    public int RefreshRecruit(string uid, string name, string ip, string re_no)
    {
        int res = 0;
        Open();
        SqlCommand MyCommand = MyConnection.CreateCommand();
        SqlTransaction MyTrans = MyConnection.BeginTransaction("Tran");
        MyCommand.Connection = MyConnection;
        MyCommand.Transaction = MyTrans;
        try
        {
            string[] id = re_no.Split(',');
            for (int i = 0; i < id.Length; i++)
            {
                MyCommand.CommandText = " select * from recruit where re_no=@re_no ";
                MyCommand.Parameters.Add("@re_no", SqlDbType.BigInt).Value = id[i];
                DataTable dt = new DataTable();
                SqlDataAdapter da = new SqlDataAdapter(MyCommand);
                da.Fill(dt);
                if (dt != null && dt.Rows.Count > 0)
                {
                    string memo = "";
                    if (string.IsNullOrEmpty(memo))
                        memo = "招聘职位：" + dt.Rows[0]["re_name"].ToString() + "，将状态进行刷新";
                    MyCommand.CommandText = "update recruit set re_modifytime=getdate(),re_modifyip=@re_modifyip where re_no=@re_no ";
                    MyCommand.Parameters.Add("@re_modifyip", SqlDbType.NVarChar).Value = ip;
                    res = MyCommand.ExecuteNonQuery();
                    if (res > 0)
                    {
                        MyCommand.CommandText = "insert into recruitrefresh (rr_reno,rr_refreshtime,rr_refreship) values (@re_no,getDate(),@re_modifyip) ";
                        MyCommand.ExecuteNonQuery();
                        WriteLog(uid, 2, ip, "用户【" + name + "】，在招聘管理功能中进行了招聘职位修改操作，修改记录为【" + memo + "】。", MyCommand);
                    }
                }
                MyCommand.Parameters.Clear();
            }
            MyTrans.Commit();
            res = 1;
        }
        catch (Exception ex)
        {
            MyTrans.Rollback("Tran");
            res = -1;
        }
        Close();
        return res;
    }

    /// <summary>
    /// 保存企业缴费记录
    /// </summary>
    /// <param name="data"></param>
    /// <returns></returns>
    public int SaveCompanyPay(Hashtable data)
    {
        int res;
        Open();
        SqlCommand MyCommand = MyConnection.CreateCommand();
        SqlTransaction MyTrans;
        MyTrans = MyConnection.BeginTransaction("Tran");
        MyCommand.Connection = MyConnection;
        MyCommand.Transaction = MyTrans;
        try
        {
            MyCommand.Parameters.Add("@cu_no", SqlDbType.BigInt).Value = data["cu_no"];
            MyCommand.Parameters.Add("@cm_money", SqlDbType.Decimal).Value = data["cm_money"];
            MyCommand.Parameters.Add("@cm_memo", SqlDbType.NText).Value = data["cm_memo"];
            MyCommand.Parameters.Add("@user", SqlDbType.NVarChar).Value = data["user"];
            MyCommand.Parameters.Add("@ip", SqlDbType.NVarChar).Value = data["ip"];

            MyCommand.CommandText = " select * from companyuser where cu_no=@cu_no ";
            DataTable dt = new DataTable();
            SqlDataAdapter da = new SqlDataAdapter(MyCommand);
            da.Fill(dt);
            if (dt != null && dt.Rows.Count > 0)
            {
                MyCommand.CommandText = " insert into compayment (cm_cuno,cm_money,cm_memo,cm_inserttime,cm_insertuser,cm_insertip) values (@cu_no,@cm_money,@cm_memo,getdate(),@user,@ip) ";
                res = MyCommand.ExecuteNonQuery();
                if (res > 0)
                    WriteLog(data["user"].ToString(), 1, data["ip"].ToString(), "用户【" + data["name"].ToString() + "】，在招聘企业管理功能中进行了缴费新增操作，新增记录为【单位名称：" + data["cu_name"] + "，费用：" + data["cm_money"] + "，备注：" + data["cm_memo"] + "】。", MyCommand);
                else
                    res = -1;
            }
            else
                res = 0;
            MyTrans.Commit();
        }
        catch
        {
            MyTrans.Rollback("Tran");
            res = -1;
        }
        Close();
        return res;
    }

    /// <summary>
    /// 删除企业缴费记录
    /// </summary>
    /// <param name="uid"></param>
    /// <param name="name"></param>
    /// <param name="ip"></param>
    /// <param name="cm_no"></param>
    /// <returns></returns>
    public int DeleteCompanyPay(string uid, string name, string ip, string cm_no)
    {
        int res = 0;
        Open();
        SqlCommand MyCommand = MyConnection.CreateCommand();
        SqlTransaction MyTrans = MyConnection.BeginTransaction("Tran");
        MyCommand.Connection = MyConnection;
        MyCommand.Transaction = MyTrans;
        try
        {
            string[] id = cm_no.Split(',');
            for (int i = 0; i < id.Length; i++)
            {
                MyCommand.CommandText = " select * from compayment left join companyuser on cm_cuno=cu_no where cm_no=@cm_no ";
                MyCommand.Parameters.Add("@cm_no", SqlDbType.BigInt).Value = id[i];
                DataTable dt = new DataTable();
                SqlDataAdapter da = new SqlDataAdapter(MyCommand);
                da.Fill(dt);
                if (dt != null && dt.Rows.Count > 0)
                {
                    string memo = "招聘企业：" + dt.Rows[0]["cu_name"].ToString() + "，" + dt.Rows[0]["cm_inserttime"].ToString() + "添加的费用[" + dt.Rows[0]["cm_money"].ToString() + "]";
                    MyCommand.CommandText = "delete from compayment where cm_no=@cm_no ";
                    res = MyCommand.ExecuteNonQuery();
                    if (res > 0)
                        WriteLog(uid, 3, ip, "用户【" + name + "】，在企业缴费记录管理功能中进行了缴费记录删除操作，删除记录为【" + memo + "】。", MyCommand);
                }
                MyCommand.Parameters.Clear();
            }
            MyTrans.Commit();
            res = 1;
        }
        catch (Exception ex)
        {
            MyTrans.Rollback("Tran");
            res = -1;
        }
        Close();
        return res;
    }

    /// <summary>
    /// 审核企业图片
    /// </summary>
    /// <param name="uid"></param>
    /// <param name="name"></param>
    /// <param name="ip"></param>
    /// <param name="cu_no"></param>
    /// <param name="cu_logostate"></param>
    /// <returns></returns>
    public int CheckComPicture(string uid, string name, string ip, string cu_no, string cu_logostate)
    {
        int res = 0;
        Open();
        SqlCommand MyCommand = MyConnection.CreateCommand();
        SqlTransaction MyTrans = MyConnection.BeginTransaction("Tran");
        MyCommand.Connection = MyConnection;
        MyCommand.Transaction = MyTrans;
        try
        {
            string[] id = cu_no.Split(',');
            for (int i = 0; i < id.Length; i++)
            {
                MyCommand.CommandText = " select * from companyuser where cu_no=@cu_no ";
                MyCommand.Parameters.Add("@cu_no", SqlDbType.BigInt).Value = id[i];
                DataTable dt = new DataTable();
                SqlDataAdapter da = new SqlDataAdapter(MyCommand);
                da.Fill(dt);
                if (dt != null && dt.Rows.Count > 0)
                {
                    string memo = "";
                    if (!cu_logostate.Equals(dt.Rows[0]["cu_logostate"].ToString()))
                    {
                        string s1 = "已审通过";
                        if (ConfigurationManager.AppSettings["Unaudited"].Equals(dt.Rows[0]["cu_logostate"].ToString()))
                            s1 = "未审";
                        else if (ConfigurationManager.AppSettings["NoAudited"].Equals(dt.Rows[0]["cu_logostate"].ToString()))
                            s1 = "已审未通过";
                        string s2 = "已审通过";
                        if (ConfigurationManager.AppSettings["Unaudited"].Equals(cu_logostate))
                            s2 = "未审";
                        else if (ConfigurationManager.AppSettings["NoAudited"].Equals(dt.Rows[0]["cu_logostate"].ToString()))
                            s2 = "已审未通过";
                        memo = "企业会员：" + dt.Rows[0]["cu_name"].ToString() + "，将图片状态从[" + s1 + "]改为[" + s2 + "]";
                    }
                    if (string.IsNullOrEmpty(memo))
                        memo = "企业会员：" + dt.Rows[0]["cu_name"].ToString() + "，未修改任何字段";
                    MyCommand.CommandText = "update companyuser set cu_logostate=@cu_logostate where cu_no=@cu_no ";
                    MyCommand.Parameters.Add("@cu_logostate", SqlDbType.Int).Value = cu_logostate;
                    res = MyCommand.ExecuteNonQuery();
                    if (res > 0)
                        WriteLog(uid, 2, ip, "用户【" + name + "】，在企业图片管理功能中进行了企业图片修改操作，修改记录为【" + memo + "】。", MyCommand);
                }
                MyCommand.Parameters.Clear();
            }
            MyTrans.Commit();
            res = 1;
        }
        catch (Exception ex)
        {
            MyTrans.Rollback("Tran");
            res = -1;
        }
        Close();
        return res;
    }

    /// <summary>
    /// 删除企业图片
    /// </summary>
    /// <param name="uid"></param>
    /// <param name="name"></param>
    /// <param name="ip"></param>
    /// <param name="cu_no"></param>
    /// <returns></returns>
    public int DeleteComPicture(string uid, string name, string ip, string cu_no)
    {
        int res = 0;
        Open();
        SqlCommand MyCommand = MyConnection.CreateCommand();
        SqlTransaction MyTrans = MyConnection.BeginTransaction("Tran");
        MyCommand.Connection = MyConnection;
        MyCommand.Transaction = MyTrans;
        try
        {
            string[] id = cu_no.Split(',');
            for (int i = 0; i < id.Length; i++)
            {
                MyCommand.CommandText = " select * from companyuser where cu_no=@cu_no ";
                MyCommand.Parameters.Add("@cu_no", SqlDbType.BigInt).Value = id[i];
                DataTable dt = new DataTable();
                SqlDataAdapter da = new SqlDataAdapter(MyCommand);
                da.Fill(dt);
                if (dt != null && dt.Rows.Count > 0)
                {
                    string memo = "企业会员：" + dt.Rows[0]["cu_name"].ToString() + "，将图片删除";
                    MyCommand.CommandText = "update companyuser set cu_logo=@cu_logo,cu_logostate=@cu_logostate where cu_no=@cu_no";
                    MyCommand.Parameters.Add("@cu_logo", SqlDbType.NVarChar).Value = DBNull.Value;
                    MyCommand.Parameters.Add("@cu_logostate", SqlDbType.Int).Value = 0;
                    res = MyCommand.ExecuteNonQuery();
                    if (res > 0)
                        WriteLog(uid, 3, ip, "用户【" + name + "】，在企业图片管理功能中进行了会员照片删除操作，删除记录为【" + memo + "】。", MyCommand);
                }
                MyCommand.Parameters.Clear();
            }
            MyTrans.Commit();
            res = 1;
        }
        catch (Exception ex)
        {
            MyTrans.Rollback("Tran");
            res = -1;
        }
        Close();
        return res;
    }

    /// <summary>
    /// 审核紧缺人才
    /// </summary>
    /// <param name="uid"></param>
    /// <param name="name"></param>
    /// <param name="ip"></param>
    /// <param name="re_no"></param>
    /// <param name="re_needstate"></param>
    /// <returns></returns>
    public int CheckTalent(string uid, string name, string ip, string re_no, string re_needstate)
    {
        int res = 0;
        Open();
        SqlCommand MyCommand = MyConnection.CreateCommand();
        SqlTransaction MyTrans = MyConnection.BeginTransaction("Tran");
        MyCommand.Connection = MyConnection;
        MyCommand.Transaction = MyTrans;
        try
        {
            string[] id = re_no.Split(',');
            for (int i = 0; i < id.Length; i++)
            {
                MyCommand.CommandText = " select * from recruit where re_no=@re_no ";
                MyCommand.Parameters.Add("@re_no", SqlDbType.BigInt).Value = id[i];
                DataTable dt = new DataTable();
                SqlDataAdapter da = new SqlDataAdapter(MyCommand);
                da.Fill(dt);
                if (dt != null && dt.Rows.Count > 0)
                {
                    string memo = "";
                    if (!re_needstate.Equals(dt.Rows[0]["re_needstate"].ToString()))
                    {
                        string s1 = "未审核";
                        if ("1".Equals(dt.Rows[0]["re_needstate"].ToString()))
                            s1 = "已审通过";
                        else if ("2".Equals(dt.Rows[0]["re_needstate"].ToString()))
                            s1 = "已审未通过";
                        string s2 = "已审";
                        if ("1".Equals(re_needstate))
                            s2 = "已审通过";
                        else if ("2".Equals(re_needstate))
                            s1 = "已审未通过";
                        memo = "招聘职位：" + dt.Rows[0]["re_name"].ToString() + "，将紧缺状态从[" + s1 + "]改为[" + s2 + "]";
                    }
                    if (string.IsNullOrEmpty(memo))
                        memo = "招聘职位：" + dt.Rows[0]["re_name"].ToString() + "，未修改任何字段";
                    MyCommand.CommandText = "update recruit set re_needstate=@re_needstate where re_no=@re_no ";
                    MyCommand.Parameters.Add("@re_needstate", SqlDbType.Int).Value = re_needstate;
                    res = MyCommand.ExecuteNonQuery();
                    if (res > 0)
                        WriteLog(uid, 2, ip, "用户【" + name + "】，在紧缺人才审核功能中进行了紧缺人才修改操作，修改记录为【" + memo + "】。", MyCommand);
                }
                MyCommand.Parameters.Clear();
            }
            MyTrans.Commit();
            res = 1;
        }
        catch (Exception ex)
        {
            MyTrans.Rollback("Tran");
            res = -1;
        }
        Close();
        return res;
    }

    /// <summary>
    /// 删除紧缺人才
    /// </summary>
    /// <param name="uid"></param>
    /// <param name="name"></param>
    /// <param name="ip"></param>
    /// <param name="re_no"></param>
    /// <returns></returns>
    public int DeleteTalent(string uid, string name, string ip, string re_no)
    {
        int res = 0;
        Open();
        SqlCommand MyCommand = MyConnection.CreateCommand();
        SqlTransaction MyTrans = MyConnection.BeginTransaction("Tran");
        MyCommand.Connection = MyConnection;
        MyCommand.Transaction = MyTrans;
        try
        {
            string[] id = re_no.Split(',');
            for (int i = 0; i < id.Length; i++)
            {
                MyCommand.CommandText = " select * from recruit where re_no=@re_no ";
                MyCommand.Parameters.Add("@re_no", SqlDbType.BigInt).Value = id[i];
                DataTable dt = new DataTable();
                SqlDataAdapter da = new SqlDataAdapter(MyCommand);
                da.Fill(dt);
                if (dt != null && dt.Rows.Count > 0)
                {
                    string memo = "招聘职位：" + dt.Rows[0]["re_name"].ToString() + "，将紧缺状态删除";
                    MyCommand.CommandText = "update recruit set re_need=@re_need,re_needstate=@re_needstate where re_no=@re_no";
                    MyCommand.Parameters.Add("@re_need", SqlDbType.Int).Value = 0;
                    MyCommand.Parameters.Add("@re_needstate", SqlDbType.Int).Value = 0;
                    res = MyCommand.ExecuteNonQuery();
                    if (res > 0)
                        WriteLog(uid, 3, ip, "用户【" + name + "】，在紧缺人才审核功能中进行了紧缺人才删除操作，删除记录为【" + memo + "】。", MyCommand);
                }
                MyCommand.Parameters.Clear();
            }
            MyTrans.Commit();
            res = 1;
        }
        catch (Exception ex)
        {
            MyTrans.Rollback("Tran");
            res = -1;
        }
        Close();
        return res;
    }

    /// <summary>
    /// 获得会员等级
    /// </summary>
    /// <param name="cl_no"></param>
    /// <returns></returns>
    public Hashtable GetLevel(string cl_no)
    {
        Open();
        SqlCommand MyCommand = new SqlCommand();
        MyCommand.Connection = MyConnection;

        MyCommand.CommandText = "select * from companylevel where cl_no=@cl_no";
        MyCommand.Parameters.Add("@cl_no", SqlDbType.BigInt).Value = cl_no;
        DataTable dt = new DataTable();
        SqlDataAdapter adapter = new SqlDataAdapter(MyCommand);
        adapter.Fill(dt);
        Close();
        ArrayList da = DataTable2ArrayList(dt);
        return da.Count > 0 ? (Hashtable)da[0] : null;
    }

    /// <summary>
    /// 保存会员等级
    /// </summary>
    /// <param name="data"></param>
    /// <returns></returns>
    public int SaveLevel(Hashtable data)
    {
        int res;
        Open();
        SqlCommand MyCommand = MyConnection.CreateCommand();
        SqlTransaction MyTrans;
        MyTrans = MyConnection.BeginTransaction("Tran");
        MyCommand.Connection = MyConnection;
        MyCommand.Transaction = MyTrans;
        try
        {
            MyCommand.Parameters.Add("@cl_id", SqlDbType.NVarChar).Value = data["cl_id"];
            MyCommand.Parameters.Add("@cl_name", SqlDbType.NVarChar).Value = data["cl_name"];
            if (string.IsNullOrEmpty(data["cl_ad"].ToString()))
                MyCommand.Parameters.Add("@cl_ad", SqlDbType.Int).Value = DBNull.Value;
            else
                MyCommand.Parameters.Add("@cl_ad", SqlDbType.Int).Value = data["cl_ad"];
            MyCommand.Parameters.Add("@cl_recruit", SqlDbType.Int).Value = data["cl_recruit"];
            MyCommand.Parameters.Add("@cl_message", SqlDbType.Int).Value = data["cl_message"];
            MyCommand.Parameters.Add("@cl_state", SqlDbType.Int).Value = data["cl_state"];
            MyCommand.Parameters.Add("@user", SqlDbType.NVarChar).Value = data["user"];
            MyCommand.Parameters.Add("@ip", SqlDbType.NVarChar).Value = data["ip"];

            if (string.IsNullOrEmpty(data["cl_no"].ToString()))
            {
                MyCommand.CommandText = " select count(cl_no) from companylevel where cl_id=@cl_id or cl_name=@cl_name ";
                Int64 count = Convert.ToInt64(MyCommand.ExecuteScalar());
                if (count == 0)
                {
                    MyCommand.CommandText = " insert into companylevel (cl_id,cl_name,cl_ad,cl_recruit,cl_message,cl_state) values (@cl_id,@cl_name,@cl_ad,@cl_recruit,@cl_message,@cl_state) ";
                    res = MyCommand.ExecuteNonQuery();
                    if (res > 0)
                        WriteLog(data["user"].ToString(), 1, data["ip"].ToString(), "用户【" + data["name"].ToString() + "】，在会员等级设置功能中进行了新增会员等级操作，新增记录为【编号：" + data["cl_id"] + "，名称：" + data["cl_name"] + "】。", MyCommand);
                    else
                        res = -1;
                }
                else
                    res = 2;
            }
            else
            {
                MyCommand.CommandText = " select count(cl_no) from companylevel where cl_no<>@cl_no and (cl_id=@cl_id or cl_name=@cl_name) ";
                MyCommand.Parameters.Add("@cl_no", SqlDbType.BigInt).Value = data["cl_no"];
                Int64 count = Convert.ToInt64(MyCommand.ExecuteScalar());
                if (count == 0)
                {
                    MyCommand.CommandText = " select * from companylevel where cl_no=@cl_no ";
                    DataTable dt = new DataTable();
                    SqlDataAdapter da = new SqlDataAdapter(MyCommand);
                    da.Fill(dt);
                    string memo = "";
                    if (dt != null && dt.Rows.Count > 0)
                    {
                        if (!data["cl_id"].ToString().Equals(dt.Rows[0]["cl_id"].ToString()))
                            memo = "会员等级：" + dt.Rows[0]["cl_name"].ToString() + "，将编号从[" + dt.Rows[0]["cl_id"].ToString() + "]改为[" + data["cl_id"].ToString() + "]";
                        if (!data["cl_name"].ToString().Equals(dt.Rows[0]["cl_name"].ToString()))
                        {
                            if (string.IsNullOrEmpty(memo))
                                memo = "会员等级：" + dt.Rows[0]["cl_name"].ToString() + "，将名称从[" + dt.Rows[0]["cl_name"].ToString() + "]改为[" + data["cl_name"].ToString() + "]";
                            else
                                memo += "；将名称从[" + dt.Rows[0]["cl_name"].ToString() + "]改为[" + data["cl_name"].ToString() + "]";
                        }
                        if (!data["cl_ad"].ToString().Equals(dt.Rows[0]["cl_ad"].ToString()))
                        {
                            string s1 = "资讯左侧图片广告";
                            if ("2".Equals(dt.Rows[0]["cl_ad"].ToString()))
                                s1 = "LOGO条右侧广告";
                            else if ("3".Equals(dt.Rows[0]["cl_ad"].ToString()))
                                s1 = "导航条下侧通栏广告";
                            else if ("4".Equals(dt.Rows[0]["cl_ad"].ToString()))
                                s1 = "搜索栏下侧通栏广告";
                            else if ("5".Equals(dt.Rows[0]["cl_ad"].ToString()))
                                s1 = "VIP招聘下侧通栏广告";
                            else if ("6".Equals(dt.Rows[0]["cl_ad"].ToString()))
                                s1 = "左右两侧挂边广告";
                            string s2 = "资讯左侧图片广告";
                            if ("2".Equals(data["cl_ad"].ToString()))
                                s2 = "LOGO条右侧广告";
                            else if ("3".Equals(data["cl_ad"].ToString()))
                                s2 = "导航条下侧通栏广告";
                            else if ("4".Equals(data["cl_ad"].ToString()))
                                s2 = "搜索栏下侧通栏广告";
                            else if ("5".Equals(data["cl_ad"].ToString()))
                                s2 = "VIP招聘下侧通栏广告";
                            else if ("6".Equals(data["cl_ad"].ToString()))
                                s2 = "左右两侧挂边广告";
                            if (string.IsNullOrEmpty(memo))
                                memo = "角色：" + dt.Rows[0]["ac_name"].ToString() + "，将广告位从[" + s1 + "]改为[" + s2 + "]";
                            else
                                memo += "；将广告位从[" + s1 + "]改为[" + s2 + "]";
                        }
                        if (!data["cl_recruit"].ToString().Equals(dt.Rows[0]["cl_recruit"].ToString()))
                        {
                            if (string.IsNullOrEmpty(memo))
                                memo = "会员等级：" + dt.Rows[0]["cl_name"].ToString() + "，将招聘职位上限从[" + dt.Rows[0]["cl_recruit"].ToString() + "]改为[" + data["cl_recruit"].ToString() + "]";
                            else
                                memo += "；将招聘职位上限从[" + dt.Rows[0]["cl_recruit"].ToString() + "]改为[" + data["cl_recruit"].ToString() + "]";
                        }
                        if (!data["cl_message"].ToString().Equals(dt.Rows[0]["cl_message"].ToString()))
                        {
                            if (string.IsNullOrEmpty(memo))
                                memo = "会员等级：" + dt.Rows[0]["cl_name"].ToString() + "，将短信上限从[" + dt.Rows[0]["cl_message"].ToString() + "]改为[" + data["cl_message"].ToString() + "]";
                            else
                                memo += "；将短信上限从[" + dt.Rows[0]["cl_message"].ToString() + "]改为[" + data["cl_message"].ToString() + "]";
                        }
                        if (!data["cl_state"].ToString().Equals(dt.Rows[0]["cl_state"].ToString()))
                        {
                            string s1 = "启用";
                            if ("0".Equals(dt.Rows[0]["cl_state"].ToString()))
                                s1 = "禁用";
                            string s2 = "启用";
                            if ("0".Equals(data["cl_state"].ToString()))
                                s2 = "禁用";
                            if (string.IsNullOrEmpty(memo))
                                memo = "会员等级：" + dt.Rows[0]["cl_name"].ToString() + "，将状态从[" + s1 + "]改为[" + s2 + "]";
                            else
                                memo += "；将状态从[" + s1 + "]改为[" + s2 + "]";
                        }
                        MyCommand.CommandText = " update companylevel set cl_id=@cl_id,cl_name=@cl_name,cl_ad=@cl_ad,cl_recruit=@cl_recruit,cl_message=@cl_message,cl_state=@cl_state where cl_no=@cl_no ";
                        res = MyCommand.ExecuteNonQuery();
                        if (res > 0)
                            WriteLog(data["user"].ToString(), 2, data["ip"].ToString(), "用户【" + data["name"].ToString() + "】，在会员等级设置功能中进行了会员等级修改操作，修改记录为【" + memo + "】。", MyCommand);
                        else
                            res = -1;
                    }
                    else
                        res = 0;
                }
                else
                    res = 2;
            }
            MyTrans.Commit();
        }
        catch
        {
            MyTrans.Rollback("Tran");
            res = -1;
        }
        Close();
        return res;
    }

    /// <summary>
    /// 删除会员等级
    /// </summary>
    /// <param name="uid"></param>
    /// <param name="name"></param>
    /// <param name="ip"></param>
    /// <param name="cl_no"></param>
    /// <returns></returns>
    public int DeleteLevel(string uid, string name, string ip, string cl_no)
    {
        int res = 0;
        Open();
        SqlCommand MyCommand = MyConnection.CreateCommand();
        SqlTransaction MyTrans = MyConnection.BeginTransaction("Tran");
        MyCommand.Connection = MyConnection;
        MyCommand.Transaction = MyTrans;
        try
        {
            string[] id = cl_no.Split(',');
            for (int i = 0; i < id.Length; i++)
            {
                MyCommand.CommandText = " select * from companylevel where cl_no=@cl_no ";
                MyCommand.Parameters.Add("@cl_no", SqlDbType.BigInt).Value = id[i];
                DataTable dt = new DataTable();
                SqlDataAdapter da = new SqlDataAdapter(MyCommand);
                da.Fill(dt);
                if (dt != null && dt.Rows.Count > 0)
                {
                    string memo = "会员等级：" + dt.Rows[0]["cl_name"].ToString();
                    MyCommand.CommandText = "delete from companylevel where cl_no=@cl_no ";
                    res = MyCommand.ExecuteNonQuery();
                    if (res > 0)
                        WriteLog(uid, 3, ip, "用户【" + name + "】，在会员等级设置功能中进行了会员等级删除操作，删除记录为【" + memo + "】。", MyCommand);
                }
                MyCommand.Parameters.Clear();
            }
            MyTrans.Commit();
            res = 1;
        }
        catch (Exception ex)
        {
            MyTrans.Rollback("Tran");
            res = -1;
        }
        Close();
        return res;
    }

    /// <summary>
    /// 批量隐藏/显示会员等级
    /// </summary>
    /// <param name="uid"></param>
    /// <param name="name"></param>
    /// <param name="ip"></param>
    /// <param name="cl_no"></param>
    /// <param name="cl_state"></param>
    /// <returns></returns>
    public int LockLevel(string uid, string name, string ip, string cl_no, string cl_state)
    {
        int res = 0;
        Open();
        SqlCommand MyCommand = MyConnection.CreateCommand();
        SqlTransaction MyTrans = MyConnection.BeginTransaction("Tran");
        MyCommand.Connection = MyConnection;
        MyCommand.Transaction = MyTrans;
        try
        {
            string[] id = cl_no.Split(',');
            for (int i = 0; i < id.Length; i++)
            {
                MyCommand.CommandText = " select * from companylevel where cl_no=@cl_no ";
                MyCommand.Parameters.Add("@cl_no", SqlDbType.BigInt).Value = id[i];
                DataTable dt = new DataTable();
                SqlDataAdapter da = new SqlDataAdapter(MyCommand);
                da.Fill(dt);
                if (dt != null && dt.Rows.Count > 0)
                {
                    string memo = "";
                    if (!cl_state.Equals(dt.Rows[0]["cl_state"].ToString()))
                    {
                        string s1 = "隐藏";
                        if ("1".Equals(dt.Rows[0]["cl_state"].ToString()))
                            s1 = "显示";
                        string s2 = "隐藏";
                        if ("1".Equals(cl_state))
                            s2 = "显示";
                        memo = "会员等级：" + dt.Rows[0]["cl_name"].ToString() + "，将状态从[" + s1 + "]改为[" + s2 + "]";
                    }
                    if (string.IsNullOrEmpty(memo))
                        memo = "会员等级：" + dt.Rows[0]["cl_name"].ToString() + "，未修改任何字段";
                    MyCommand.CommandText = "update companylevel set cl_state=@cl_state where cl_no=@cl_no ";
                    MyCommand.Parameters.Add("@cl_state", SqlDbType.Int).Value = cl_state;
                    res = MyCommand.ExecuteNonQuery();
                    if (res > 0)
                        WriteLog(uid, 2, ip, "用户【" + name + "】，在会员等级设置功能中进行了会员等级修改操作，修改记录为【" + memo + "】。", MyCommand);
                }
                MyCommand.Parameters.Clear();
            }
            MyTrans.Commit();
            res = 1;
        }
        catch (Exception ex)
        {
            MyTrans.Rollback("Tran");
            res = -1;
        }
        Close();
        return res;
    }

    /// <summary>
    /// 个人信息
    /// </summary>
    /// <param name="pi_no"></param>
    /// <returns></returns>
    public Hashtable GetPerson(string pi_no)
    {
        Open();
        SqlCommand MyCommand = new SqlCommand();
        MyCommand.Connection = MyConnection;

        MyCommand.CommandText = "select *,(select di_name from dictionary where di_type=5 and di_code=pi_sex) as sex,(select di_name from dictionary where di_type=4 and di_code=pi_edu) as edu,(select di_name from dictionary where di_type=3 and di_code=pi_hometown) as hometown,(select di_name from dictionary where di_type=3 and di_code=pi_workarea) as workarea,(select di_name from dictionary where di_type=6 and di_code=pi_jobtype) as jobtype,(select ma_name from major where ma_id=pi_spcode) as spcode,(select jt_name from jobtype where jt_id=pi_yx1) as yx1,(select jt_name from jobtype where jt_id=pi_yx2) as yx2,(select jt_name from jobtype where jt_id=pi_yx11) as yx11,(select jt_name from jobtype where jt_id=pi_yx22) as yx22 from personinfor where pi_no=@pi_no";
        MyCommand.Parameters.Add("@pi_no", SqlDbType.BigInt).Value = pi_no;
        DataTable data = new DataTable();
        SqlDataAdapter adapter = new SqlDataAdapter(MyCommand);
        adapter.Fill(data);
        Close();
        ArrayList da = DataTable2ArrayList(data);
        return da.Count > 0 ? (Hashtable)da[0] : null;
    }

    /// <summary>
    /// 教育经历
    /// </summary>
    /// <param name="pi_no"></param>
    /// <returns></returns>
    public DataTable GetStudyList(string pi_no)
    {
        Open();
        SqlCommand MyCommand = new SqlCommand();
        MyCommand.Connection = MyConnection;

        MyCommand.CommandText = "select * from education left join dictionary on di_type=4 and di_code=ed_edu where ed_pino=@pi_no";
        MyCommand.Parameters.Add("@pi_no", SqlDbType.BigInt).Value = pi_no;
        DataTable data = new DataTable();
        SqlDataAdapter adapter = new SqlDataAdapter(MyCommand);
        adapter.Fill(data);
        Close();
        return data;
    }

    /// <summary>
    /// 工作经历
    /// </summary>
    /// <param name="pi_no"></param>
    /// <returns></returns>
    public DataTable GetWorkList(string pi_no)
    {
        Open();
        SqlCommand MyCommand = new SqlCommand();
        MyCommand.Connection = MyConnection;

        MyCommand.CommandText = "select *,(select jt_name from jobtype where jt_id=wo_position) as position,(select jt_name from jobtype where jt_id=wo_position2) as position2 from work where wo_pino=@pi_no";
        MyCommand.Parameters.Add("@pi_no", SqlDbType.BigInt).Value = pi_no;
        DataTable data = new DataTable();
        SqlDataAdapter adapter = new SqlDataAdapter(MyCommand);
        adapter.Fill(data);
        Close();
        return data;
    }

    /// <summary>
    /// 审核个人会员
    /// </summary>
    /// <param name="uid"></param>
    /// <param name="name"></param>
    /// <param name="ip"></param>
    /// <param name="pi_no"></param>
    /// <param name="pi_state"></param>
    /// <returns></returns>
    public int CheckPerson(string uid, string name, string ip, string pi_no, string pi_state)
    {
        int res = 0;
        Open();
        SqlCommand MyCommand = MyConnection.CreateCommand();
        SqlTransaction MyTrans = MyConnection.BeginTransaction("Tran");
        MyCommand.Connection = MyConnection;
        MyCommand.Transaction = MyTrans;
        try
        {
            string[] id = pi_no.Split(',');
            for (int i = 0; i < id.Length; i++)
            {
                MyCommand.CommandText = " select * from personinfor where pi_no=@pi_no ";
                MyCommand.Parameters.Add("@pi_no", SqlDbType.BigInt).Value = id[i];
                DataTable dt = new DataTable();
                SqlDataAdapter da = new SqlDataAdapter(MyCommand);
                da.Fill(dt);
                if (dt != null && dt.Rows.Count > 0)
                {
                    string memo = "";
                    if (!pi_state.Equals(dt.Rows[0]["pi_state"].ToString()))
                    {
                        string s1 = "未审核";
                        if ("1".Equals(dt.Rows[0]["pi_state"].ToString()))
                            s1 = "已审通过";
                        else if ("2".Equals(dt.Rows[0]["pi_state"].ToString()))
                            s1 = "已审未通过";
                        string s2 = "未审核";
                        if ("1".Equals(pi_state))
                            s2 = "已审通过";
                        else if ("2".Equals(pi_state))
                            s2 = "已审未通过";
                        memo = "个人会员：" + dt.Rows[0]["pi_name"].ToString() + "，将状态从[" + s1 + "]改为[" + s2 + "]";
                    }
                    if (string.IsNullOrEmpty(memo))
                        memo = "个人会员：" + dt.Rows[0]["pi_name"].ToString() + "，未修改任何字段";
                    MyCommand.CommandText = "update personinfor set pi_state=@pi_state where pi_no=@pi_no ";
                    MyCommand.Parameters.Add("@pi_state", SqlDbType.Int).Value = pi_state;
                    res = MyCommand.ExecuteNonQuery();
                    if (res > 0)
                        WriteLog(uid, 2, ip, "用户【" + name + "】，在求职人才管理功能中进行了数据修改操作，修改记录为【" + memo + "】。", MyCommand);
                }
                MyCommand.Parameters.Clear();
            }
            MyTrans.Commit();
            res = 1;
        }
        catch (Exception ex)
        {
            MyTrans.Rollback("Tran");
            res = -1;
        }
        Close();
        return res;
    }

    /// <summary>
    /// 删除个人会员
    /// </summary>
    /// <param name="uid"></param>
    /// <param name="name"></param>
    /// <param name="ip"></param>
    /// <param name="pi_no"></param>
    /// <returns></returns>
    public int DeletePerson(string uid, string name, string ip, string pi_no)
    {
        int res = 0;
        Open();
        SqlCommand MyCommand = MyConnection.CreateCommand();
        SqlTransaction MyTrans = MyConnection.BeginTransaction("Tran");
        MyCommand.Connection = MyConnection;
        MyCommand.Transaction = MyTrans;
        try
        {
            string[] id = pi_no.Split(',');
            for (int i = 0; i < id.Length; i++)
            {
                MyCommand.CommandText = " select * from personinfor where pi_no=@pi_no ";
                MyCommand.Parameters.Add("@pi_no", SqlDbType.BigInt).Value = id[i];
                DataTable dt = new DataTable();
                SqlDataAdapter da = new SqlDataAdapter(MyCommand);
                da.Fill(dt);
                if (dt != null && dt.Rows.Count > 0)
                {
                    string memo = "个人会员：" + dt.Rows[0]["pi_name"].ToString();
                    MyCommand.CommandText = "delete from personinfor where pi_no=@pi_no ";
                    res = MyCommand.ExecuteNonQuery();
                    if (res > 0)
                        WriteLog(uid, 3, ip, "用户【" + name + "】，在求职人才管理功能中进行了数据删除操作，删除记录为【" + memo + "】。", MyCommand);
                }
                MyCommand.Parameters.Clear();
            }
            MyTrans.Commit();
            res = 1;
        }
        catch (Exception ex)
        {
            MyTrans.Rollback("Tran");
            res = -1;
        }
        Close();
        return res;
    }

    /// <summary>
    /// 隐藏/显示个人简历
    /// </summary>
    /// <param name="uid"></param>
    /// <param name="name"></param>
    /// <param name="ip"></param>
    /// <param name="pi_no"></param>
    /// <param name="pi_hide"></param>
    /// <returns></returns>
    public int LockPerson(string uid, string name, string ip, string pi_no, string pi_hide)
    {
        int res = 0;
        Open();
        SqlCommand MyCommand = MyConnection.CreateCommand();
        SqlTransaction MyTrans = MyConnection.BeginTransaction("Tran");
        MyCommand.Connection = MyConnection;
        MyCommand.Transaction = MyTrans;
        try
        {
            string[] id = pi_no.Split(',');
            for (int i = 0; i < id.Length; i++)
            {
                MyCommand.CommandText = " select * from personinfor where pi_no=@pi_no ";
                MyCommand.Parameters.Add("@pi_no", SqlDbType.BigInt).Value = id[i];
                DataTable dt = new DataTable();
                SqlDataAdapter da = new SqlDataAdapter(MyCommand);
                da.Fill(dt);
                if (dt != null && dt.Rows.Count > 0)
                {
                    string memo = "";
                    if (!pi_hide.Equals(dt.Rows[0]["pi_hide"].ToString()))
                    {
                        string s1 = "开启";
                        if (ConfigurationManager.AppSettings["Close"].Equals(dt.Rows[0]["pi_hide"].ToString()))
                            s1 = "关闭";
                        else if (ConfigurationManager.AppSettings["Half"].Equals(dt.Rows[0]["pi_hide"].ToString()))
                            s1 = "半开启";
                        string s2 = "开启";
                        if (ConfigurationManager.AppSettings["Close"].Equals(pi_hide))
                            s2 = "关闭";
                        else if (ConfigurationManager.AppSettings["Half"].Equals(pi_hide))
                            s1 = "半开启";
                        memo = "个人会员：" + dt.Rows[0]["pi_name"].ToString() + "，将简历状态从[" + s1 + "]改为[" + s2 + "]";
                    }
                    if (string.IsNullOrEmpty(memo))
                        memo = "个人会员：" + dt.Rows[0]["pi_name"].ToString() + "，未修改任何字段";
                    MyCommand.CommandText = "update personinfor set pi_hide=@pi_hide where pi_no=@pi_no ";
                    MyCommand.Parameters.Add("@pi_hide", SqlDbType.Int).Value = pi_hide;
                    res = MyCommand.ExecuteNonQuery();
                    if (res > 0)
                        WriteLog(uid, 2, ip, "用户【" + name + "】，在求职人才管理功能中进行了数据修改操作，修改记录为【" + memo + "】。", MyCommand);
                }
                MyCommand.Parameters.Clear();
            }
            MyTrans.Commit();
            res = 1;
        }
        catch (Exception ex)
        {
            MyTrans.Rollback("Tran");
            res = -1;
        }
        Close();
        return res;
    }

    /// <summary>
    /// 审核个人照片
    /// </summary>
    /// <param name="uid"></param>
    /// <param name="name"></param>
    /// <param name="ip"></param>
    /// <param name="pi_no"></param>
    /// <param name="pi_picstate"></param>
    /// <returns></returns>
    public int CheckPerPicture(string uid, string name, string ip, string pi_no, string pi_picstate)
    {
        int res = 0;
        Open();
        SqlCommand MyCommand = MyConnection.CreateCommand();
        SqlTransaction MyTrans = MyConnection.BeginTransaction("Tran");
        MyCommand.Connection = MyConnection;
        MyCommand.Transaction = MyTrans;
        try
        {
            string[] id = pi_no.Split(',');
            for (int i = 0; i < id.Length; i++)
            {
                MyCommand.CommandText = " select * from personinfor where pi_no=@pi_no ";
                MyCommand.Parameters.Add("@pi_no", SqlDbType.BigInt).Value = id[i];
                DataTable dt = new DataTable();
                SqlDataAdapter da = new SqlDataAdapter(MyCommand);
                da.Fill(dt);
                if (dt != null && dt.Rows.Count > 0)
                {
                    string memo = "";
                    if (!pi_picstate.Equals(dt.Rows[0]["pi_picstate"].ToString()))
                    {
                        string s1 = "未审核";
                        if ("1".Equals(dt.Rows[0]["pi_picstate"].ToString()))
                            s1 = "已审通过";
                        else if ("2".Equals(dt.Rows[0]["pi_picstate"].ToString()))
                            s1 = "已审未通过";
                        string s2 = "未审核";
                        if ("1".Equals(pi_picstate))
                            s2 = "已审通过";
                        else if ("2".Equals(pi_picstate))
                            s2 = "已审未通过";
                        memo = "个人会员：" + dt.Rows[0]["pi_name"].ToString() + "，将照片状态从[" + s1 + "]改为[" + s2 + "]";
                    }
                    if (string.IsNullOrEmpty(memo))
                        memo = "个人会员：" + dt.Rows[0]["pi_name"].ToString() + "，未修改任何字段";
                    MyCommand.CommandText = "update personinfor set pi_picstate=@pi_picstate where pi_no=@pi_no ";
                    MyCommand.Parameters.Add("@pi_picstate", SqlDbType.Int).Value = pi_picstate;
                    res = MyCommand.ExecuteNonQuery();
                    if (res > 0)
                        WriteLog(uid, 2, ip, "用户【" + name + "】，在个人照片管理功能中进行了数据修改操作，修改记录为【" + memo + "】。", MyCommand);
                }
                MyCommand.Parameters.Clear();
            }
            MyTrans.Commit();
            res = 1;
        }
        catch (Exception ex)
        {
            MyTrans.Rollback("Tran");
            res = -1;
        }
        Close();
        return res;
    }

    /// <summary>
    /// 删除个人照片
    /// </summary>
    /// <param name="uid"></param>
    /// <param name="name"></param>
    /// <param name="ip"></param>
    /// <param name="pi_no"></param>
    /// <returns></returns>
    public int DeletePerPicture(string uid, string name, string ip, string pi_no)
    {
        int res = 0;
        Open();
        SqlCommand MyCommand = MyConnection.CreateCommand();
        SqlTransaction MyTrans = MyConnection.BeginTransaction("Tran");
        MyCommand.Connection = MyConnection;
        MyCommand.Transaction = MyTrans;
        try
        {
            string[] id = pi_no.Split(',');
            for (int i = 0; i < id.Length; i++)
            {
                MyCommand.CommandText = " select * from personinfor where pi_no=@pi_no ";
                MyCommand.Parameters.Add("@pi_no", SqlDbType.BigInt).Value = id[i];
                DataTable dt = new DataTable();
                SqlDataAdapter da = new SqlDataAdapter(MyCommand);
                da.Fill(dt);
                if (dt != null && dt.Rows.Count > 0)
                {
                    string memo = "个人会员：" + dt.Rows[0]["pi_name"].ToString() + "将照片删除";
                    MyCommand.CommandText = "update personinfor set pi_pic=@pi_pic,pi_picstate=@pi_picstate where pi_no=@pi_no";
                    MyCommand.Parameters.Add("@pi_pic", SqlDbType.NVarChar).Value = DBNull.Value;
                    MyCommand.Parameters.Add("@pi_picstate", SqlDbType.Int).Value = 0;
                    res = MyCommand.ExecuteNonQuery();
                    if (res > 0)
                        WriteLog(uid, 3, ip, "用户【" + name + "】，在个人照片管理功能中进行了会员照片删除操作，删除记录为【" + memo + "】。", MyCommand);
                }
                MyCommand.Parameters.Clear();
            }
            MyTrans.Commit();
            res = 1;
        }
        catch (Exception ex)
        {
            MyTrans.Rollback("Tran");
            res = -1;
        }
        Close();
        return res;
    }

    /// <summary>
    /// 审核高级人才
    /// </summary>
    /// <param name="uid"></param>
    /// <param name="name"></param>
    /// <param name="ip"></param>
    /// <param name="pi_no"></param>
    /// <param name="pi_highstate"></param>
    /// <returns></returns>
    public int CheckPerHigh(string uid, string name, string ip, string pi_no, string pi_highstate)
    {
        int res = 0;
        Open();
        SqlCommand MyCommand = MyConnection.CreateCommand();
        SqlTransaction MyTrans = MyConnection.BeginTransaction("Tran");
        MyCommand.Connection = MyConnection;
        MyCommand.Transaction = MyTrans;
        try
        {
            string[] id = pi_no.Split(',');
            for (int i = 0; i < id.Length; i++)
            {
                MyCommand.CommandText = " select * from personinfor where pi_no=@pi_no ";
                MyCommand.Parameters.Add("@pi_no", SqlDbType.BigInt).Value = id[i];
                DataTable dt = new DataTable();
                SqlDataAdapter da = new SqlDataAdapter(MyCommand);
                da.Fill(dt);
                if (dt != null && dt.Rows.Count > 0)
                {
                    string memo = "";
                    if (!pi_highstate.Equals(dt.Rows[0]["pi_highstate"].ToString()))
                    {
                        string s1 = "未审核";
                        if ("1".Equals(dt.Rows[0]["pi_highstate"].ToString()))
                            s1 = "已审通过";
                        else if ("2".Equals(dt.Rows[0]["pi_highstate"].ToString()))
                            s1 = "已审未通过";
                        string s2 = "未审核";
                        if ("1".Equals(pi_highstate))
                            s2 = "已审通过";
                        else if ("2".Equals(pi_highstate))
                            s2 = "已审未通过";
                        memo = "个人会员：" + dt.Rows[0]["pi_name"].ToString() + "，将高级人才状态从[" + s1 + "]改为[" + s2 + "]";
                    }
                    if (string.IsNullOrEmpty(memo))
                        memo = "个人会员：" + dt.Rows[0]["pi_name"].ToString() + "，未修改任何字段";
                    MyCommand.CommandText = "update personinfor set pi_highstate=@pi_highstate where pi_no=@pi_no ";
                    MyCommand.Parameters.Add("@pi_highstate", SqlDbType.Int).Value = pi_highstate;
                    res = MyCommand.ExecuteNonQuery();
                    if (res > 0)
                        WriteLog(uid, 2, ip, "用户【" + name + "】，在高级人才审核功能中进行了数据修改操作，修改记录为【" + memo + "】。", MyCommand);
                }
                MyCommand.Parameters.Clear();
            }
            MyTrans.Commit();
            res = 1;
        }
        catch (Exception ex)
        {
            MyTrans.Rollback("Tran");
            res = -1;
        }
        Close();
        return res;
    }

    /// <summary>
    /// 删除高级人才
    /// </summary>
    /// <param name="uid"></param>
    /// <param name="name"></param>
    /// <param name="ip"></param>
    /// <param name="pi_no"></param>
    /// <returns></returns>
    public int DeletePerHigh(string uid, string name, string ip, string pi_no)
    {
        int res = 0;
        Open();
        SqlCommand MyCommand = MyConnection.CreateCommand();
        SqlTransaction MyTrans = MyConnection.BeginTransaction("Tran");
        MyCommand.Connection = MyConnection;
        MyCommand.Transaction = MyTrans;
        try
        {
            string[] id = pi_no.Split(',');
            for (int i = 0; i < id.Length; i++)
            {
                MyCommand.CommandText = " select * from personinfor where pi_no=@pi_no ";
                MyCommand.Parameters.Add("@pi_no", SqlDbType.BigInt).Value = id[i];
                DataTable dt = new DataTable();
                SqlDataAdapter da = new SqlDataAdapter(MyCommand);
                da.Fill(dt);
                if (dt != null && dt.Rows.Count > 0)
                {
                    string memo = "个人会员：" + dt.Rows[0]["pi_name"].ToString() + "将高级人才标志删除";
                    MyCommand.CommandText = "update personinfor set pi_high=@pi_high,pi_highstate=@pi_highstate where pi_no=@pi_no";
                    MyCommand.Parameters.Add("@pi_high", SqlDbType.Int).Value = 0;
                    MyCommand.Parameters.Add("@pi_highstate", SqlDbType.Int).Value = 0;
                    res = MyCommand.ExecuteNonQuery();
                    if (res > 0)
                        WriteLog(uid, 3, ip, "用户【" + name + "】，在高级人才审核功能中进行了会员照片删除操作，删除记录为【" + memo + "】。", MyCommand);
                }
                MyCommand.Parameters.Clear();
            }
            MyTrans.Commit();
            res = 1;
        }
        catch (Exception ex)
        {
            MyTrans.Rollback("Tran");
            res = -1;
        }
        Close();
        return res;
    }

    /// <summary>
    /// 获取招聘会
    /// </summary>
    /// <param name="nw_no"></param>
    /// <returns></returns>
    public Hashtable GetFair(string jf_no)
    {
        Open();
        SqlCommand MyCommand = new SqlCommand();
        MyCommand.Connection = MyConnection;

        MyCommand.CommandText = "select * from jobfair where jf_no=@jf_no";
        MyCommand.Parameters.Add("@jf_no", SqlDbType.BigInt).Value = jf_no;
        DataTable data = new DataTable();
        SqlDataAdapter adapter = new SqlDataAdapter(MyCommand);
        adapter.Fill(data);
        Close();
        ArrayList da = DataTable2ArrayList(data);
        return da.Count > 0 ? (Hashtable)da[0] : null;
    }

    /// <summary>
    /// 保存招聘会
    /// </summary>
    /// <param name="data"></param>
    /// <returns></returns>
    public Int64 SaveFair(Hashtable data)
    {
        Int64 res = 0;
        Open();
        SqlCommand MyCommand = MyConnection.CreateCommand();
        SqlTransaction MyTrans;
        MyTrans = MyConnection.BeginTransaction("Tran");
        MyCommand.Connection = MyConnection;
        MyCommand.Transaction = MyTrans;
        try
        {
            MyCommand.Parameters.Add("@jf_name", SqlDbType.NVarChar).Value = data["jf_name"];
            MyCommand.Parameters.Add("@jf_type", SqlDbType.Int).Value = data["jf_type"];
            MyCommand.Parameters.Add("@jf_time", SqlDbType.DateTime).Value = data["jf_time"];
            MyCommand.Parameters.Add("@jf_url", SqlDbType.NVarChar).Value = data["jf_url"];
            MyCommand.Parameters.Add("@jf_memo", SqlDbType.NText).Value = data["jf_memo"];
            MyCommand.Parameters.Add("@user", SqlDbType.NVarChar).Value = data["user"];
            MyCommand.Parameters.Add("@ip", SqlDbType.NVarChar).Value = data["ip"];
            if ("true".Equals(data["jf_enter"]))
                MyCommand.Parameters.Add("@jf_enter", SqlDbType.Int).Value = 1;
            else
                MyCommand.Parameters.Add("@jf_enter", SqlDbType.Int).Value = 0;
            if ("true".Equals(data["jf_hide"]))
                MyCommand.Parameters.Add("@jf_hide", SqlDbType.Int).Value = 1;
            else
                MyCommand.Parameters.Add("@jf_hide", SqlDbType.Int).Value = 0;
            if ("true".Equals(data["jf_red"]))
                MyCommand.Parameters.Add("@jf_red", SqlDbType.Int).Value = 1;
            else
                MyCommand.Parameters.Add("@jf_red", SqlDbType.Int).Value = 0;
            if (data["jf_closetime"] == null || string.IsNullOrEmpty(data["jf_closetime"].ToString()))
                MyCommand.Parameters.Add("@jf_closetime", SqlDbType.DateTime).Value = DBNull.Value;
            else
                MyCommand.Parameters.Add("@jf_closetime", SqlDbType.DateTime).Value = data["jf_closetime"];

            if (string.IsNullOrEmpty(data["jf_no"].ToString()))
            {
                //MyCommand.CommandText = " select count(1) from jobfair where jf_name=@jf_name ";
                //Int64 count = Convert.ToInt64(MyCommand.ExecuteScalar());
                //if (count == 0)
                //{
                if (!"true".Equals(data["nw_orderid"]))
                    MyCommand.CommandText = " insert into jobfair (jf_name,jf_type,jf_time,jf_closetime,jf_url,jf_memo,jf_enter,jf_hide,jf_orderid,jf_red,jf_inserttime,jf_insertip,jf_insertuser,jf_modifytime,jf_modifyip,jf_modifyuser,jf_hits) values (@jf_name,@jf_type,@jf_time,@jf_closetime,@jf_url,@jf_memo,@jf_enter,@jf_hide,0,@jf_red,getdate(),@ip,@user,getdate(),@ip,@user,0);select @@Identity ";
                else
                    MyCommand.CommandText = " insert into jobfair select @jf_name,@jf_type,@jf_time,@jf_closetime,@jf_url,@jf_memo,@jf_enter,@jf_hide,isnull(MAX(jf_orderid),0)+1,@jf_red,getdate(),@ip,@user,getdate(),@ip,@user,null,0 from jobfair;select @@Identity ";
                res = Convert.ToInt64(MyCommand.ExecuteScalar());
                //res = MyCommand.ExecuteNonQuery();
                string str = data["jf_memo"].ToString();
                while (str.Contains("/upload/file/"))
                {
                    string f = str.Substring(str.IndexOf("/upload/file/") - 1, 1);
                    str = str.Substring(str.IndexOf("/upload/file/"));
                    string url = str.Substring(str.IndexOf("/upload/file/"), str.IndexOf(f));
                    str = str.Substring(str.IndexOf(f) + 1);
                    MyCommand.CommandText = " update uploadfile set uf_nwno=@uf_nwno,uf_type=2 where uf_url=@uf_url ";
                    MyCommand.Parameters.Add("@uf_nwno", SqlDbType.BigInt).Value = res;
                    MyCommand.Parameters.Add("@uf_url", SqlDbType.NVarChar).Value = url;
                    MyCommand.ExecuteNonQuery();
                    MyCommand.Parameters.Clear();
                }
                if (res > 0)
                {
                    WriteLog(data["user"].ToString(), 1, data["ip"].ToString(), "用户【" + data["name"].ToString() + "】，在招聘会管理功能中进行了招聘会新增操作，新增记录为【标题：" + data["jf_name"] + "】。", MyCommand);
                    res = 1;
                }
                else
                    res = -1;
                //}
                //else
                //    res = 2;
            }
            else
            {
                //MyCommand.CommandText = " select count(1) from jobfair where jf_no<>@jf_no and jf_name=@jf_name ";
                MyCommand.Parameters.Add("@jf_no", SqlDbType.BigInt).Value = data["jf_no"];
                //Int64 count = Convert.ToInt64(MyCommand.ExecuteScalar());
                //if (count == 0)
                //{
                MyCommand.CommandText = " select count(1) from fairentry where fe_jfno=@jf_no ";
                Int64 count2 = Convert.ToInt64(MyCommand.ExecuteScalar());
                if (count2 == 0)
                {
                    MyCommand.CommandText = " select * from jobfair where jf_no=@jf_no ";
                    DataTable dt = new DataTable();
                    SqlDataAdapter da = new SqlDataAdapter(MyCommand);
                    da.Fill(dt);
                    if (dt != null && dt.Rows.Count > 0)
                    {
                        string memo = "";
                        if (!data["jf_name"].ToString().Equals(dt.Rows[0]["jf_name"].ToString()))
                            memo = "招聘会：" + dt.Rows[0]["jf_name"].ToString() + "，将标题从[" + dt.Rows[0]["jf_name"].ToString() + "]改为[" + data["jf_name"] + "]";
                        if (!data["jf_type"].ToString().Equals(dt.Rows[0]["jf_type"].ToString()))
                        {
                            string type1 = "";
                            if ("1".Equals(dt.Rows[0]["jf_type"].ToString()))
                                type1 = "组团招聘";
                            else if ("2".Equals(dt.Rows[0]["jf_type"].ToString()))
                                type1 = "周六人才集市";
                            string type2 = "";
                            if ("1".Equals(data["jf_type"].ToString()))
                                type2 = "组团招聘";
                            else if ("2".Equals(data["jf_type"].ToString()))
                                type2 = "周六人才集市";
                            if (string.IsNullOrEmpty(memo))
                                memo = "招聘会：" + dt.Rows[0]["jf_name"].ToString() + "，将类型从[" + type1 + "]改为[" + type2 + "]";
                            else
                                memo += "；将类型从[" + type1 + "]改为[" + type2 + "]";
                        }
                        if (!data["jf_time"].ToString().Equals(dt.Rows[0]["jf_time"].ToString()))
                        {
                            if (string.IsNullOrEmpty(memo))
                                memo = "招聘会：" + dt.Rows[0]["jf_name"].ToString() + "，将举办日期从[" + dt.Rows[0]["jf_time"].ToString() + "]改为[" + data["jf_time"] + "]";
                            else
                                memo += "；将举办日期从[" + dt.Rows[0]["jf_time"].ToString() + "]改为[" + data["jf_time"] + "]";
                        }
                        if (!data["jf_url"].ToString().Equals(dt.Rows[0]["jf_url"].ToString()))
                        {
                            if (string.IsNullOrEmpty(memo))
                                memo = "招聘会：" + dt.Rows[0]["jf_name"].ToString() + "，将引用地址从[" + dt.Rows[0]["jf_url"].ToString() + "]改为[" + data["jf_url"] + "]";
                            else
                                memo += "；将引用地址从[" + dt.Rows[0]["jf_url"].ToString() + "]改为[" + data["jf_url"] + "]";
                        }
                        if (("true".Equals(data["jf_enter"]) && "0".Equals(dt.Rows[0]["jf_enter"].ToString())) || ("false".Equals(data["jf_enter"]) && "1".Equals(dt.Rows[0]["jf_enter"].ToString())))
                        {
                            string s1 = "不允许";
                            if ("1".Equals(dt.Rows[0]["jf_enter"].ToString()))
                                s1 = "允许";
                            string s2 = "不允许";
                            if (("true".Equals(data["jf_enter"])))
                                s2 = "允许";
                            if (string.IsNullOrEmpty(memo))
                                memo = "招聘会：" + dt.Rows[0]["jf_name"].ToString() + "，将报名状态从[" + s1 + "]改为[" + s2 + "]";
                            else
                                memo += "；将状态从[" + s1 + "]改为[" + s2 + "]";
                        }
                        if (("true".Equals(data["jf_hide"]) && "0".Equals(dt.Rows[0]["jf_hide"].ToString())) || ("false".Equals(data["jf_hide"]) && "1".Equals(dt.Rows[0]["jf_hide"].ToString())))
                        {
                            string s1 = "显示";
                            if ("1".Equals(dt.Rows[0]["jf_hide"].ToString()))
                                s1 = "隐藏";
                            string s2 = "显示";
                            if (("true".Equals(data["jf_hide"])))
                                s2 = "隐藏";
                            if (string.IsNullOrEmpty(memo))
                                memo = "招聘会：" + dt.Rows[0]["jf_name"].ToString() + "，将状态从[" + s1 + "]改为[" + s2 + "]";
                            else
                                memo += "；将状态从[" + s1 + "]改为[" + s2 + "]";
                        }
                        if (("true".Equals(data["jf_orderid"]) && ("0".Equals(dt.Rows[0]["jf_orderid"].ToString()))) || ("false".Equals(data["jf_orderid"]) && (!"0".Equals(dt.Rows[0]["jf_orderid"].ToString()))))
                        {
                            string s1 = "置顶";
                            if ("0".Equals(dt.Rows[0]["jf_orderid"].ToString()))
                                s1 = "不置顶";
                            string s2 = "置顶";
                            if (("false".Equals(data["jf_orderid"])))
                                s2 = "不置顶";
                            if (string.IsNullOrEmpty(memo))
                                memo = "招聘会：" + dt.Rows[0]["jf_name"].ToString() + "，将置顶从[" + s1 + "]改为[" + s2 + "]";
                            else
                                memo += "；将置顶从[" + s1 + "]改为[" + s2 + "]";
                        }
                        if (("true".Equals(data["jf_red"]) && "0".Equals(dt.Rows[0]["jf_red"].ToString())) || ("false".Equals(data["jf_red"]) && "1".Equals(dt.Rows[0]["jf_red"].ToString())))
                        {
                            string s1 = "描红";
                            if ("0".Equals(dt.Rows[0]["jf_red"].ToString()))
                                s1 = "不描红";
                            string s2 = "描红";
                            if (("false".Equals(data["jf_red"])))
                                s2 = "不描红";
                            if (string.IsNullOrEmpty(memo))
                                memo = "招聘会：" + dt.Rows[0]["jf_name"].ToString() + "，设置描红从[" + s1 + "]改为[" + s2 + "]";
                            else
                                memo += "；将描红从[" + s1 + "]改为[" + s2 + "]";
                        }
                        if (!data["jf_memo"].ToString().Equals(dt.Rows[0]["jf_memo"].ToString()))
                        {
                            if (string.IsNullOrEmpty(memo))
                                memo = "招聘会：" + dt.Rows[0]["jf_name"].ToString() + "，将内容进行了修改";
                            else
                                memo += "；将内容进行了修改";
                        }
                        if (string.IsNullOrEmpty(memo))
                            memo = "招聘会：" + dt.Rows[0]["jf_name"].ToString() + "，未修改任何字段";
                        if (!"true".Equals(data["jf_orderid"]))
                            MyCommand.CommandText = " update jobfair set jf_name=@jf_name,jf_type=@jf_type,jf_time=@jf_time,jf_closetime=@jf_closetime,jf_url=@jf_url,jf_enter=@jf_enter,jf_hide=@jf_hide,jf_orderid=0,jf_red=@jf_red,jf_memo=@jf_memo,jf_modifytime=getdate(),jf_modifyip=@ip,jf_modifyuser=@user where jf_no=@jf_no ";
                        else if ("true".Equals(data["jf_orderid"]) && !"0".Equals(dt.Rows[0]["jf_orderid"].ToString()))
                            MyCommand.CommandText = " update jobfair set jf_name=@jf_name,jf_type=@jf_type,jf_time=@jf_time,jf_closetime=@jf_closetime,jf_url=@jf_url,jf_enter=@jf_enter,jf_hide=@jf_hide,jf_red=@jf_red,jf_memo=@jf_memo,jf_modifytime=getdate(),jf_modifyip=@ip,jf_modifyuser=@user where jf_no=@jf_no ";
                        else
                            MyCommand.CommandText = " update jobfair set jf_name=@jf_name,jf_type=@jf_type,jf_time=@jf_time,jf_closetime=@jf_closetime,jf_url=@jf_url,jf_enter=@jf_enter,jf_hide=@jf_hide,jf_orderid=(select isnull(MAX(jf_orderid),0) + 1 from jobfair),jf_red=@jf_red,jf_memo=@jf_memo,jf_modifytime=getdate(),jf_modifyip=@ip,jf_modifyuser=@user where jf_no=@jf_no ";
                        res = MyCommand.ExecuteNonQuery();
                        string str = data["jf_memo"].ToString();
                        while (str.Contains("/upload/file/"))
                        {
                            string f = str.Substring(str.IndexOf("/upload/file/") - 1, 1);
                            str = str.Substring(str.IndexOf("/upload/file/"));
                            string url = str.Substring(str.IndexOf("/upload/file/"), str.IndexOf(f));
                            str = str.Substring(str.IndexOf(f) + 1);
                            MyCommand.CommandText = " update uploadfile set uf_nwno=@uf_nwno,uf_type=2 where uf_url=@uf_url ";
                            MyCommand.Parameters.Add("@uf_nwno", SqlDbType.BigInt).Value = data["jf_no"];
                            MyCommand.Parameters.Add("@uf_url", SqlDbType.NVarChar).Value = url;
                            MyCommand.ExecuteNonQuery();
                            MyCommand.Parameters.Clear();
                        }
                        if (res > 0)
                            WriteLog(data["user"].ToString(), 2, data["ip"].ToString(), "用户【" + data["name"].ToString() + "】，在招聘会管理功能中进行了招聘会修改操作，修改记录为【" + memo + "】。", MyCommand);
                    }
                    else
                        res = 0;
                }
                else
                    res = 3;
                //}
                //else
                //    res = 2;
            }

            MyTrans.Commit();
        }
        catch
        {
            MyTrans.Rollback("Tran");
            res = -1;
        }
        Close();
        return res;
    }

    /// <summary>
    /// 删除招聘会
    /// </summary>
    /// <param name="uid"></param>
    /// <param name="name"></param>
    /// <param name="ip"></param>
    /// <param name="jf_no"></param>
    /// <returns></returns>
    public int DeleteFair(string uid, string name, string ip, string jf_no)
    {
        int res = 0;
        Open();
        SqlCommand MyCommand = MyConnection.CreateCommand();
        SqlTransaction MyTrans = MyConnection.BeginTransaction("Tran");
        MyCommand.Connection = MyConnection;
        MyCommand.Transaction = MyTrans;
        try
        {
            string[] id = jf_no.Split(',');
            for (int i = 0; i < id.Length; i++)
            {
                MyCommand.CommandText = " select * from jobfair where jf_no=@jf_no ";
                MyCommand.Parameters.Add("@jf_no", SqlDbType.BigInt).Value = id[i];
                DataTable dt = new DataTable();
                SqlDataAdapter da = new SqlDataAdapter(MyCommand);
                da.Fill(dt);
                if (dt != null && dt.Rows.Count > 0)
                {
                    MyCommand.CommandText = " select count(1) from fairentry where fe_jfno=@jf_no ";
                    Int64 count2 = Convert.ToInt64(MyCommand.ExecuteScalar());
                    if (count2 == 0)
                    {
                        string memo = "招聘会：" + dt.Rows[0]["jf_name"].ToString();
                        MyCommand.CommandText = "delete from jobfair where jf_no=@jf_no ";
                        res = MyCommand.ExecuteNonQuery();
                        if (res > 0)
                            WriteLog(uid, 3, ip, "用户【" + name + "】，在招聘会管理功能中进行了招聘会删除操作，删除记录为【" + memo + "】。", MyCommand);
                    }
                    else
                    {
                        MyTrans.Rollback("Tran");
                        Close();
                        return -2;
                    }
                }
                MyCommand.Parameters.Clear();
            }
            MyTrans.Commit();
            res = 1;
        }
        catch (Exception ex)
        {
            MyTrans.Rollback("Tran");
            res = -1;
        }
        Close();
        return res;
    }

    /// <summary>
    /// 设置报名招聘会
    /// </summary>
    /// <param name="uid"></param>
    /// <param name="name"></param>
    /// <param name="ip"></param>
    /// <param name="jf_no"></param>
    /// <param name="jf_enter"></param>
    /// <returns></returns>
    public int EnterFair(string uid, string name, string ip, string jf_no, string jf_enter)
    {
        int res = 0;
        Open();
        SqlCommand MyCommand = MyConnection.CreateCommand();
        SqlTransaction MyTrans = MyConnection.BeginTransaction("Tran");
        MyCommand.Connection = MyConnection;
        MyCommand.Transaction = MyTrans;
        try
        {
            string[] id = jf_no.Split(',');
            for (int i = 0; i < id.Length; i++)
            {
                MyCommand.CommandText = " select * from jobfair where jf_no=@jf_no ";
                MyCommand.Parameters.Add("@jf_no", SqlDbType.BigInt).Value = id[i];
                DataTable dt = new DataTable();
                SqlDataAdapter da = new SqlDataAdapter(MyCommand);
                da.Fill(dt);
                if (dt != null && dt.Rows.Count > 0)
                {
                    string memo = "";
                    if (!jf_enter.Equals(dt.Rows[0]["jf_enter"].ToString()))
                    {
                        string s1 = "允许";
                        if ("0".Equals(dt.Rows[0]["jf_enter"].ToString()))
                            s1 = "不允许";
                        string s2 = "允许";
                        if ("0".Equals(jf_enter))
                            s2 = "不允许";
                        memo = "招聘会：" + dt.Rows[0]["jf_name"].ToString() + "，将报名状态从[" + s1 + "]改为[" + s2 + "]";
                    }
                    if (string.IsNullOrEmpty(memo))
                        memo = "招聘会：" + dt.Rows[0]["jf_name"].ToString() + "，未修改任何字段";
                    MyCommand.CommandText = "update jobfair set jf_enter=@jf_enter where jf_no=@jf_no ";
                    MyCommand.Parameters.Add("@jf_enter", SqlDbType.Int).Value = jf_enter;
                    res = MyCommand.ExecuteNonQuery();
                    if (res > 0)
                        WriteLog(uid, 2, ip, "用户【" + name + "】，在招聘会管理功能中进行了招聘会修改操作，修改记录为【" + memo + "】。", MyCommand);
                }
                MyCommand.Parameters.Clear();
            }
            MyTrans.Commit();
            res = 1;
        }
        catch (Exception ex)
        {
            MyTrans.Rollback("Tran");
            res = -1;
        }
        Close();
        return res;
    }

    /// <summary>
    /// 隐藏/显示招聘会
    /// </summary>
    /// <param name="uid"></param>
    /// <param name="name"></param>
    /// <param name="ip"></param>
    /// <param name="jf_no"></param>
    /// <param name="jf_hide"></param>
    /// <returns></returns>
    public int LockFair(string uid, string name, string ip, string jf_no, string jf_hide)
    {
        int res = 0;
        Open();
        SqlCommand MyCommand = MyConnection.CreateCommand();
        SqlTransaction MyTrans = MyConnection.BeginTransaction("Tran");
        MyCommand.Connection = MyConnection;
        MyCommand.Transaction = MyTrans;
        try
        {
            string[] id = jf_no.Split(',');
            for (int i = 0; i < id.Length; i++)
            {
                MyCommand.CommandText = " select * from jobfair where jf_no=@jf_no ";
                MyCommand.Parameters.Add("@jf_no", SqlDbType.BigInt).Value = id[i];
                DataTable dt = new DataTable();
                SqlDataAdapter da = new SqlDataAdapter(MyCommand);
                da.Fill(dt);
                if (dt != null && dt.Rows.Count > 0)
                {
                    string memo = "";
                    if (!jf_hide.Equals(dt.Rows[0]["jf_hide"].ToString()))
                    {
                        string s1 = "隐藏";
                        if ("0".Equals(dt.Rows[0]["jf_hide"].ToString()))
                            s1 = "显示";
                        string s2 = "隐藏";
                        if ("0".Equals(jf_hide))
                            s2 = "显示";
                        memo = "招聘会：" + dt.Rows[0]["jf_name"].ToString() + "，将状态从[" + s1 + "]改为[" + s2 + "]";
                    }
                    if (string.IsNullOrEmpty(memo))
                        memo = "招聘会：" + dt.Rows[0]["jf_name"].ToString() + "，未修改任何字段";
                    MyCommand.CommandText = "update jobfair set jf_hide=@jf_hide where jf_no=@jf_no ";
                    MyCommand.Parameters.Add("@jf_hide", SqlDbType.Int).Value = jf_hide;
                    res = MyCommand.ExecuteNonQuery();
                    if (res > 0)
                        WriteLog(uid, 2, ip, "用户【" + name + "】，在招聘会管理功能中进行了招聘会修改操作，修改记录为【" + memo + "】。", MyCommand);
                }
                MyCommand.Parameters.Clear();
            }
            MyTrans.Commit();
            res = 1;
        }
        catch (Exception ex)
        {
            MyTrans.Rollback("Tran");
            res = -1;
        }
        Close();
        return res;
    }

    /// <summary>
    /// 置顶/取消招聘会
    /// </summary>
    /// <param name="uid"></param>
    /// <param name="name"></param>
    /// <param name="ip"></param>
    /// <param name="jf_no"></param>
    /// <param name="jf_orderid"></param>
    /// <returns></returns>
    public int TopFair(string uid, string name, string ip, string jf_no, string jf_orderid)
    {
        int res = 0;
        Open();
        SqlCommand MyCommand = MyConnection.CreateCommand();
        SqlTransaction MyTrans = MyConnection.BeginTransaction("Tran");
        MyCommand.Connection = MyConnection;
        MyCommand.Transaction = MyTrans;
        try
        {
            MyCommand.CommandText = " select jf_name from jobfair where jf_no in (" + jf_no + ")";
            DataTable dt = new DataTable();
            SqlDataAdapter da = new SqlDataAdapter(MyCommand);
            da.Fill(dt);
            string top = "";
            if ("0".Equals(jf_orderid))
            {
                MyCommand.CommandText = "update jobfair set jf_orderid=0 where jf_no in (" + jf_no + ")";
                top = "，取消置顶";
            }
            else
            {
                MyCommand.CommandText = "update jobfair set jf_orderid=(select isnull(MAX(jf_orderid),0) + 1 from jobfair) where jf_no in (" + jf_no + ")";
                top = "，置顶";
            }
            res = MyCommand.ExecuteNonQuery();

            if (res > 0)
            {
                string memo = "招聘会：";
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    memo += dt.Rows[i]["jf_name"].ToString() + "、";
                }
                memo = memo.TrimEnd('、') + top;
                WriteLog(uid, 2, ip, "用户【" + name + "】，在招聘会管理功能中进行了招聘会修改操作，修改记录为【将" + memo + "】。", MyCommand);
            }
            MyTrans.Commit();
            res = 1;
        }
        catch (Exception ex)
        {
            MyTrans.Rollback("Tran");
            res = -1;
        }
        Close();
        return res;
    }

    /// <summary>
    /// 描红/取消招聘会
    /// </summary>
    /// <param name="uid"></param>
    /// <param name="name"></param>
    /// <param name="ip"></param>
    /// <param name="jf_no"></param>
    /// <param name="jf_red"></param>
    /// <returns></returns>
    public int RedFair(string uid, string name, string ip, string jf_no, string jf_red)
    {
        int res = 0;
        Open();
        SqlCommand MyCommand = MyConnection.CreateCommand();
        SqlTransaction MyTrans = MyConnection.BeginTransaction("Tran");
        MyCommand.Connection = MyConnection;
        MyCommand.Transaction = MyTrans;
        try
        {
            string[] id = jf_no.Split(',');
            for (int i = 0; i < id.Length; i++)
            {
                MyCommand.CommandText = " select * from jobfair where jf_no=@jf_no ";
                MyCommand.Parameters.Add("@jf_no", SqlDbType.BigInt).Value = id[i];
                DataTable dt = new DataTable();
                SqlDataAdapter da = new SqlDataAdapter(MyCommand);
                da.Fill(dt);
                if (dt != null && dt.Rows.Count > 0)
                {
                    string memo = "";
                    if (!jf_red.Equals(dt.Rows[0]["jf_red"].ToString()))
                    {
                        string s = "描红";
                        if ("0".Equals(jf_red))
                            s = "取消描红";
                        memo = "招聘会：" + dt.Rows[0]["jf_name"].ToString() + "，" + s;
                    }
                    if (string.IsNullOrEmpty(memo))
                        memo = "招聘会：" + dt.Rows[0]["jf_name"].ToString() + "，未修改任何字段";
                    MyCommand.CommandText = "update jobfair set jf_red=@jf_red where jf_no=@jf_no ";
                    MyCommand.Parameters.Add("@jf_red", SqlDbType.Int).Value = jf_red;
                    res = MyCommand.ExecuteNonQuery();
                    if (res > 0)
                        WriteLog(uid, 2, ip, "用户【" + name + "】，在招聘会管理功能中进行了招聘会修改操作，修改记录为【" + memo + "】。", MyCommand);
                }
                MyCommand.Parameters.Clear();
            }
            MyTrans.Commit();
            res = 1;
        }
        catch (Exception ex)
        {
            MyTrans.Rollback("Tran");
            res = -1;
        }
        Close();
        return res;
    }

    public int RefreshFair(string uid, string name, string ip, string jf_no, string state)
    {
        int res = 0;
        Open();
        SqlCommand MyCommand = MyConnection.CreateCommand();
        SqlTransaction MyTrans = MyConnection.BeginTransaction("Tran");
        MyCommand.Connection = MyConnection;
        MyCommand.Transaction = MyTrans;
        try
        {
            string[] id = jf_no.Split(',');
            for (int i = 0; i < id.Length; i++)
            {
                MyCommand.CommandText = " select * from jobfair where jf_no=@jf_no ";
                MyCommand.Parameters.Add("@jf_no", SqlDbType.BigInt).Value = id[i];
                DataTable dt = new DataTable();
                SqlDataAdapter da = new SqlDataAdapter(MyCommand);
                da.Fill(dt);
                if (dt != null && dt.Rows.Count > 0)
                {
                    string memo = "";
                    string s = "";
                    if ("1".Equals(state))
                    {
                        s = "刷新";
                        MyCommand.CommandText = "update jobfair set jf_modifytime=getdate() where jf_no=@jf_no ";
                    }
                    else
                    {
                        s = "取消刷新";
                        MyCommand.CommandText = "update jobfair set jf_modifytime=jf_inserttime where jf_no=@jf_no ";
                    }
                    memo = "招聘会：" + dt.Rows[0]["jf_name"].ToString() + "，" + s;
                    res = MyCommand.ExecuteNonQuery();
                    if (res > 0)
                        WriteLog(uid, 2, ip, "用户【" + name + "】，在招聘会管理功能中进行了招聘会修改操作，修改记录为【" + memo + "】。", MyCommand);
                }
                MyCommand.Parameters.Clear();
            }
            MyTrans.Commit();
            res = 1;
        }
        catch (Exception ex)
        {
            MyTrans.Rollback("Tran");
            res = -1;
        }
        Close();
        return res;
    }

    /// <summary>
    /// 获取招聘会名称
    /// </summary>
    /// <param name="cu_no"></param>
    /// <returns></returns>
    public string GetFairName(string jf_no)
    {
        string res = "";
        Open();
        try
        {
            SqlCommand MyCommand = new SqlCommand("select jf_name from jobfair where jf_no=@jf_no", MyConnection);
            MyCommand.Parameters.Add("@jf_no", SqlDbType.BigInt).Value = jf_no;
            res = MyCommand.ExecuteScalar().ToString();
        }
        catch (Exception e)
        {

        }
        Close();
        return res;
    }

    /// <summary>
    /// 审核报名企业
    /// </summary>
    /// <param name="uid"></param>
    /// <param name="name"></param>
    /// <param name="ip"></param>
    /// <param name="fe_no"></param>
    /// <param name="fe_state"></param>
    /// <returns></returns>
    public int CheckFairEntry(string uid, string name, string ip, string je_no, string je_state)
    {
        int res = 0;
        Open();
        SqlCommand MyCommand = MyConnection.CreateCommand();
        SqlTransaction MyTrans = MyConnection.BeginTransaction("Tran");
        MyCommand.Connection = MyConnection;
        MyCommand.Transaction = MyTrans;
        try
        {
            string[] id = je_no.Split(',');
            for (int i = 0; i < id.Length; i++)
            {
                MyCommand.CommandText = " select * from jobenter where je_no=@je_no ";
                MyCommand.Parameters.Add("@je_no", SqlDbType.BigInt).Value = id[i];
                DataTable dt = new DataTable();
                SqlDataAdapter da = new SqlDataAdapter(MyCommand);
                da.Fill(dt);
                if (dt != null && dt.Rows.Count > 0)
                {
                    string m = "";
                    if (!je_state.Equals(dt.Rows[0]["je_state"].ToString()))
                    {
                        string s1 = "未审核";
                        if ("1".Equals(dt.Rows[0]["je_state"].ToString()))
                            s1 = "已审通过";
                        else if ("2".Equals(dt.Rows[0]["je_state"].ToString()))
                            s1 = "已审未通过";
                        string s2 = "未审核";
                        if ("1".Equals(je_state))
                            s2 = "已审通过";
                        else if ("2".Equals(je_state))
                            s2 = "已审未通过";
                        m = "报名单位：" + dt.Rows[0]["je_name"].ToString() + "，将状态从[" + s1 + "]改为[" + s2 + "]";
                    }
                    if (string.IsNullOrEmpty(m))
                        m = "报名单位：" + dt.Rows[0]["je_name"].ToString() + "，未修改任何字段";
                    MyCommand.CommandText = "update jobenter set je_state=@je_state where je_no=@je_no ";
                    MyCommand.Parameters.Add("@je_state", SqlDbType.Int).Value = je_state;
                    MyCommand.ExecuteNonQuery();

                    MyCommand.Parameters.Clear();
                    MyCommand.CommandText = "update recruit set re_state=@re_state where re_cuno=@re_cuno and re_jobfairid=@re_jobfairid";
                    MyCommand.Parameters.Add("@re_state", SqlDbType.Int).Value = je_state == "1" ? "1" : "0";
                    MyCommand.Parameters.Add("@re_cuno", SqlDbType.BigInt).Value = dt.Rows[0]["je_cuno"].ToString();
                    MyCommand.Parameters.Add("@re_jobfairid", SqlDbType.BigInt).Value = dt.Rows[0]["je_no"].ToString();
                    MyCommand.ExecuteNonQuery();

                    if (res > 0)
                        WriteLog(uid, 2, ip, "用户【" + name + "】，在报名单位管理功能中进行了报名审核修改操作，修改记录为【" + m + "】。", MyCommand);
                }
                MyCommand.Parameters.Clear();
            }
            MyTrans.Commit();
            res = 1;
        }
        catch (Exception ex)
        {
            MyTrans.Rollback("Tran");
            res = -1;
        }
        Close();
        return res;
    }

    /// <summary>
    /// 删除报名企业
    /// </summary>
    /// <param name="uid"></param>
    /// <param name="name"></param>
    /// <param name="ip"></param>
    /// <param name="fe_no"></param>
    /// <returns></returns>
    public int DeleteFairEntry(string uid, string name, string ip, string fe_no)
    {
        int res = 0;
        Open();
        SqlCommand MyCommand = MyConnection.CreateCommand();
        SqlTransaction MyTrans = MyConnection.BeginTransaction("Tran");
        MyCommand.Connection = MyConnection;
        MyCommand.Transaction = MyTrans;
        try
        {
            string[] id = fe_no.Split(',');
            for (int i = 0; i < id.Length; i++)
            {
                MyCommand.CommandText = " select * from fairentry left join companyuser on fe_cuno=cu_no left join jobfair on fe_jfno=jf_no where fe_no=@fe_no ";
                MyCommand.Parameters.Add("@fe_no", SqlDbType.BigInt).Value = id[i];
                DataTable dt = new DataTable();
                SqlDataAdapter da = new SqlDataAdapter(MyCommand);
                da.Fill(dt);
                if (dt != null && dt.Rows.Count > 0)
                {
                    MyCommand.CommandText = " select *,(select di_name from dictionary where di_type=5 and di_code=je_sex) as sex,(select di_name from dictionary where di_type=6 and di_code=je_kind) as kind,(select di_name from dictionary where di_type=4 and di_code=je_edu) as edu," +
                    "(select di_name from dictionary where di_type=7 and di_code=je_target) as target,(select jt_name from jobtype where jt_id=je_jobtype1) as jobtype1,(select jt_name from jobtype where jt_id=je_jobtype2) as jobtype2," +
                    "(select di_name from dictionary where di_type=3 and di_code=je_area) as area from jobenter where je_feno=@je_feno ";
                    MyCommand.Parameters.Add("@je_feno", SqlDbType.BigInt).Value = id[i];
                    DataTable dt2 = new DataTable();
                    SqlDataAdapter da2 = new SqlDataAdapter(MyCommand);
                    da2.Fill(dt2);
                    for (int j = 0; j < dt2.Rows.Count; j++)
                    {
                        string m = "报名企业：" + dt.Rows[0]["cu_name"].ToString() + "参加招聘会：" + dt.Rows[0]["jf_name"].ToString() + "，报名职位：" + dt2.Rows[j]["je_name"].ToString() +
                            "，招聘人数：" + dt2.Rows[j]["je_num"].ToString() + "，性别要求：" + dt2.Rows[j]["sex"].ToString() + "，工作性质：" + dt2.Rows[j]["kind"].ToString() +
                            "，学历要求：" + dt2.Rows[j]["edu"].ToString() + dt2.Rows[j]["je_edu2"].ToString() + "，招聘对象：" + dt2.Rows[j]["target"].ToString() +
                            "，岗位类别1：" + dt2.Rows[j]["jobtype1"].ToString() + "，岗位类别2：" + dt2.Rows[j]["jobtype2"].ToString() + "，年龄要求：" + dt2.Rows[j]["je_age"].ToString() +
                            "，月薪待遇：" + dt2.Rows[j]["je_pay1"].ToString() + "-" + dt2.Rows[j]["je_pay2"].ToString() + "，工作地区：" + dt2.Rows[j]["area"].ToString() +
                            "，其他要求：" + dt2.Rows[j]["je_memo"].ToString() + "，添加时间：" + dt2.Rows[j]["je_inserttime"].ToString() + "，添加IP：" + dt2.Rows[j]["je_insertip"].ToString();
                        MyCommand.CommandText = "delete from jobenter where je_no=@je_no ";
                        MyCommand.Parameters.Add("@je_no", SqlDbType.BigInt).Value = dt2.Rows[j]["je_no"].ToString();
                        res = MyCommand.ExecuteNonQuery();
                        if (res > 0)
                            WriteLog(uid, 3, ip, "用户【" + name + "】，在报名企业管理功能中进行了报名职位删除操作，删除记录为【" + m + "】。", MyCommand);
                        MyCommand.Parameters.Clear();
                    }
                    string memo = "报名企业：" + dt.Rows[0]["cu_name"].ToString();
                    MyCommand.CommandText = "delete from fairentry where fe_no=@fe_no ";
                    res = MyCommand.ExecuteNonQuery();
                    if (res > 0)
                        WriteLog(uid, 3, ip, "用户【" + name + "】，在报名企业管理功能中进行了报名企业删除操作，删除记录为【" + memo + "】。", MyCommand);
                }
                MyCommand.Parameters.Clear();
            }
            MyTrans.Commit();
            res = 1;
        }
        catch (Exception ex)
        {
            MyTrans.Rollback("Tran");
            res = -1;
        }
        Close();
        return res;
    }

    /// <summary>
    /// 审核报名职位
    /// </summary>
    /// <param name="uid"></param>
    /// <param name="name"></param>
    /// <param name="ip"></param>
    /// <param name="fe_no"></param>
    /// <param name="fe_state"></param>
    /// <returns></returns>
    public int CheckJobEnter(string uid, string name, string ip, string je_no, string je_state)
    {
        int res = 0;
        Open();
        SqlCommand MyCommand = MyConnection.CreateCommand();
        SqlTransaction MyTrans = MyConnection.BeginTransaction("Tran");
        MyCommand.Connection = MyConnection;
        MyCommand.Transaction = MyTrans;
        try
        {
            string[] id = je_no.Split(',');
            for (int i = 0; i < id.Length; i++)
            {
                MyCommand.CommandText = " select * from jobenter where je_no=@je_no ";
                MyCommand.Parameters.Add("@je_no", SqlDbType.BigInt).Value = id[i];
                DataTable dt = new DataTable();
                SqlDataAdapter da = new SqlDataAdapter(MyCommand);
                da.Fill(dt);
                if (dt != null && dt.Rows.Count > 0)
                {
                    string memo = "";
                    if (!je_state.Equals(dt.Rows[0]["je_state"].ToString()))
                    {
                        string s1 = "未审核";
                        if ("1".Equals(dt.Rows[0]["je_state"].ToString()))
                            s1 = "已审通过";
                        else if ("2".Equals(dt.Rows[0]["je_state"].ToString()))
                            s1 = "已审未通过";
                        string s2 = "未审核";
                        if ("1".Equals(je_state))
                            s2 = "已审通过";
                        else if ("2".Equals(je_state))
                            s2 = "已审未通过";
                        memo = "报名职位：" + dt.Rows[0]["je_name"].ToString() + "，将状态从[" + s1 + "]改为[" + s2 + "]";
                    }
                    if (string.IsNullOrEmpty(memo))
                        memo = "报名职位：" + dt.Rows[0]["je_name"].ToString() + "，未修改任何字段";
                    MyCommand.CommandText = "update jobenter set je_state=@je_state where je_no=@je_no ";
                    MyCommand.Parameters.Add("@je_state", SqlDbType.Int).Value = je_state;
                    res = MyCommand.ExecuteNonQuery();
                    if (res > 0)
                        WriteLog(uid, 2, ip, "用户【" + name + "】，在报名职位管理功能中进行了报名职位修改操作，修改记录为【" + memo + "】。", MyCommand);
                }
                MyCommand.Parameters.Clear();
            }
            MyTrans.Commit();
            res = 1;
        }
        catch (Exception ex)
        {
            MyTrans.Rollback("Tran");
            res = -1;
        }
        Close();
        return res;
    }

    /// <summary>
    /// 删除报名职位
    /// </summary>
    /// <param name="uid"></param>
    /// <param name="name"></param>
    /// <param name="ip"></param>
    /// <param name="fe_no"></param>
    /// <returns></returns>
    public int DeleteJobEnter(string uid, string name, string ip, string je_no)
    {
        int res = 0;
        Open();
        SqlCommand MyCommand = MyConnection.CreateCommand();
        SqlTransaction MyTrans = MyConnection.BeginTransaction("Tran");
        MyCommand.Connection = MyConnection;
        MyCommand.Transaction = MyTrans;
        try
        {
            string[] id = je_no.Split(',');
            for (int i = 0; i < id.Length; i++)
            {
                MyCommand.CommandText = " select * from jobenter where je_no=@je_no ";
                MyCommand.Parameters.Add("@je_no", SqlDbType.BigInt).Value = id[i];
                DataTable dt = new DataTable();
                SqlDataAdapter da = new SqlDataAdapter(MyCommand);
                da.Fill(dt);
                if (dt != null && dt.Rows.Count > 0)
                {
                    string memo = "报名单位：" + dt.Rows[0]["je_name"].ToString();
                    MyCommand.CommandText = "delete from jobenter where je_no=@je_no ";
                    res = MyCommand.ExecuteNonQuery();
                    if (res > 0)
                        WriteLog(uid, 3, ip, "用户【" + name + "】，在招聘会报名单位管理功能中进行了报名单位删除操作，删除记录为【" + memo + "】。", MyCommand);
                }
                MyCommand.Parameters.Clear();
            }
            MyTrans.Commit();
            res = 1;
        }
        catch (Exception ex)
        {
            MyTrans.Rollback("Tran");
            res = -1;
        }
        Close();
        return res;
    }

    /// <summary>
    /// 根据状态获取会员等级
    /// </summary>
    /// <param name="cl_state"></param>
    /// <returns></returns>
    public DataTable GetLevelByState(int cl_state)
    {
        Open();
        SqlCommand MyCommand = new SqlCommand();
        MyCommand.Connection = MyConnection;

        MyCommand.CommandText = "select * from companylevel where cl_state=@cl_state ";
        MyCommand.Parameters.Add("@cl_state", SqlDbType.Int).Value = cl_state;
        DataTable data = new DataTable();
        SqlDataAdapter adapter = new SqlDataAdapter(MyCommand);
        adapter.Fill(data);
        Close();
        return (data);
    }


    /// <summary>
    /// 获取HR协会会员
    /// </summary>
    /// <param name="hr_no"></param>
    /// <returns></returns>
    public Hashtable GetMember(string hr_no)
    {
        Open();
        SqlCommand MyCommand = new SqlCommand();
        MyCommand.Connection = MyConnection;

        MyCommand.CommandText = "select * from hrmember where hr_no=@hr_no";
        MyCommand.Parameters.Add("@hr_no", SqlDbType.BigInt).Value = hr_no;
        DataTable data = new DataTable();
        SqlDataAdapter adapter = new SqlDataAdapter(MyCommand);
        adapter.Fill(data);
        Close();
        ArrayList da = DataTable2ArrayList(data);
        return da.Count > 0 ? (Hashtable)da[0] : null;
    }

    /// <summary>
    /// 保存HR协会会员
    /// </summary>
    /// <param name="data"></param>
    /// <returns></returns>
    public int SaveMember(Hashtable data)
    {
        int res;
        Open();
        SqlCommand MyCommand = MyConnection.CreateCommand();
        SqlTransaction MyTrans;
        MyTrans = MyConnection.BeginTransaction("Tran");
        MyCommand.Connection = MyConnection;
        MyCommand.Transaction = MyTrans;
        try
        {
            MyCommand.Parameters.Add("@hr_company", SqlDbType.NVarChar).Value = data["hr_company"];
            MyCommand.Parameters.Add("@hr_card", SqlDbType.NVarChar).Value = data["hr_card"];
            MyCommand.Parameters.Add("@hr_address", SqlDbType.NVarChar).Value = data["hr_address"];
            MyCommand.Parameters.Add("@hr_postcode", SqlDbType.NVarChar).Value = data["hr_postcode"];
            MyCommand.Parameters.Add("@hr_tel", SqlDbType.NVarChar).Value = data["hr_tel"];
            MyCommand.Parameters.Add("@hr_fax", SqlDbType.NVarChar).Value = data["hr_fax"];
            MyCommand.Parameters.Add("@hr_type", SqlDbType.NVarChar).Value = data["hr_type"];
            MyCommand.Parameters.Add("@hr_subject", SqlDbType.NVarChar).Value = data["hr_subject"];
            MyCommand.Parameters.Add("@hr_business", SqlDbType.NVarChar).Value = data["hr_business"];
            MyCommand.Parameters.Add("@hr_memo", SqlDbType.NText).Value = data["hr_memo"];
            MyCommand.Parameters.Add("@hr_name", SqlDbType.NVarChar).Value = data["hr_name"];
            MyCommand.Parameters.Add("@hr_sex", SqlDbType.NVarChar).Value = data["hr_sex"];
            MyCommand.Parameters.Add("@hr_nation", SqlDbType.NVarChar).Value = data["hr_nation"];
            MyCommand.Parameters.Add("@hr_birth", SqlDbType.NVarChar).Value = data["hr_birth"];
            MyCommand.Parameters.Add("@hr_education", SqlDbType.NVarChar).Value = data["hr_education"];
            MyCommand.Parameters.Add("@hr_political", SqlDbType.NVarChar).Value = data["hr_political"];
            MyCommand.Parameters.Add("@hr_job", SqlDbType.NVarChar).Value = data["hr_job"];
            MyCommand.Parameters.Add("@hr_technical", SqlDbType.NVarChar).Value = data["hr_technical"];
            MyCommand.Parameters.Add("@hr_phone", SqlDbType.NVarChar).Value = data["hr_phone"];
            MyCommand.Parameters.Add("@hr_mobile", SqlDbType.NVarChar).Value = data["hr_mobile"];
            MyCommand.Parameters.Add("@hr_qq", SqlDbType.NVarChar).Value = data["hr_qq"];
            MyCommand.Parameters.Add("@user", SqlDbType.NVarChar).Value = data["user"];
            MyCommand.Parameters.Add("@ip", SqlDbType.NVarChar).Value = data["ip"];
            if (string.IsNullOrEmpty(data["hr_no"].ToString()))
            {
                MyCommand.CommandText = " select count(1) from hrmember where hr_company=@hr_company ";
                int count = Convert.ToInt32(MyCommand.ExecuteScalar());
                if (count == 0)
                {
                    MyCommand.CommandText = " insert into hrmember (hr_company,hr_card,hr_address,hr_postcode,hr_tel,hr_fax,hr_type,hr_subject,hr_business,hr_memo,hr_name,hr_sex,hr_nation,hr_birth,hr_education,hr_political,hr_job,hr_technical,hr_phone,hr_mobile,hr_qq,hr_inserttime,hr_insertuser,hr_insertip,hr_hide) values (@hr_company,@hr_card,@hr_address,@hr_postcode,@hr_tel,@hr_fax,@hr_type,@hr_subject,@hr_business,@hr_memo,@hr_name,@hr_sex,@hr_nation,@hr_birth,@hr_education,@hr_political,@hr_job,@hr_technical,@hr_phone,@hr_mobile,@hr_qq,getdate(),@user,@ip,0) ";
                    res = MyCommand.ExecuteNonQuery();
                    if (res > 0)
                        WriteLog(data["user"].ToString(), 1, data["ip"].ToString(), "用户【" + data["name"].ToString() + "】，在HR协会会员管理功能中进行了数据新增操作，新增记录为【单位名称：" + data["hr_company"] + "，营业执照号：" + data["hr_card"] + "，会员代表姓名：" + data["hr_name"] + "】。", MyCommand);
                    else
                        res = -1;
                }
                else
                    res = 2;
            }
            else
            {
                MyCommand.CommandText = " select count(1) from hrmember where hr_no<>@hr_no and hr_company=@hr_company ";
                MyCommand.Parameters.Add("@hr_no", SqlDbType.BigInt).Value = data["hr_no"];
                int count = Convert.ToInt32(MyCommand.ExecuteScalar());
                if (count == 0)
                {
                    MyCommand.CommandText = " select * from hrmember left join dictionary on di_type=4 and di_code=hr_education where hr_no=@hr_no ";
                    DataTable dt = new DataTable();
                    SqlDataAdapter da = new SqlDataAdapter(MyCommand);
                    da.Fill(dt);
                    if (dt != null && dt.Rows.Count > 0)
                    {
                        string memo = "";
                        if (!data["hr_company"].ToString().Equals(dt.Rows[0]["hr_company"].ToString()))
                            memo = "HR协会会员：" + dt.Rows[0]["hr_company"].ToString() + "，将单位名称从[" + dt.Rows[0]["hr_company"].ToString() + "]改为[" + data["hr_company"] + "]";
                        if (!data["hr_card"].ToString().Equals(dt.Rows[0]["hr_card"].ToString()))
                        {
                            if (string.IsNullOrEmpty(memo))
                                memo = "HR协会会员：" + dt.Rows[0]["hr_company"].ToString() + "，将营业执照号从[" + dt.Rows[0]["hr_card"].ToString() + "]改为[" + data["hr_card"] + "]";
                            else
                                memo += "；将营业执照号从[" + dt.Rows[0]["hr_card"].ToString() + "]改为[" + data["hr_card"] + "]";
                        }
                        if (!data["hr_postcode"].ToString().Equals(dt.Rows[0]["hr_postcode"].ToString()))
                        {
                            if (string.IsNullOrEmpty(memo))
                                memo = "HR协会会员：" + dt.Rows[0]["hr_company"].ToString() + "，将邮政编码从[" + dt.Rows[0]["hr_postcode"].ToString() + "]改为[" + data["hr_postcode"] + "]";
                            else
                                memo += "；将邮政编码从[" + dt.Rows[0]["hr_postcode"].ToString() + "]改为[" + data["hr_postcode"] + "]";
                        }
                        if (!data["hr_tel"].ToString().Equals(dt.Rows[0]["hr_tel"].ToString()))
                        {
                            if (string.IsNullOrEmpty(memo))
                                memo = "HR协会会员：" + dt.Rows[0]["hr_company"].ToString() + "，将联系电话从[" + dt.Rows[0]["hr_tel"].ToString() + "]改为[" + data["hr_tel"] + "]";
                            else
                                memo += "；将联系电话从[" + dt.Rows[0]["hr_tel"].ToString() + "]改为[" + data["hr_tel"] + "]";
                        }
                        if (!data["hr_fax"].ToString().Equals(dt.Rows[0]["hr_fax"].ToString()))
                        {
                            if (string.IsNullOrEmpty(memo))
                                memo = "HR协会会员：" + dt.Rows[0]["hr_company"].ToString() + "，将传真从[" + dt.Rows[0]["hr_fax"].ToString() + "]改为[" + data["hr_fax"] + "]";
                            else
                                memo += "；将传真从[" + dt.Rows[0]["hr_fax"].ToString() + "]改为[" + data["hr_fax"] + "]";
                        }
                        if (!data["hr_type"].ToString().Equals(dt.Rows[0]["hr_type"].ToString()))
                        {
                            if (string.IsNullOrEmpty(memo))
                                memo = "HR协会会员：" + dt.Rows[0]["hr_company"].ToString() + "，将单位性质从[" + dt.Rows[0]["hr_type"].ToString() + "]改为[" + data["hr_type"] + "]";
                            else
                                memo += "；将单位性质从[" + dt.Rows[0]["hr_type"].ToString() + "]改为[" + data["hr_type"] + "]";
                        }
                        if (!data["hr_subject"].ToString().Equals(dt.Rows[0]["hr_subject"].ToString()))
                        {
                            if (string.IsNullOrEmpty(memo))
                                memo = "HR协会会员：" + dt.Rows[0]["hr_company"].ToString() + "，将隶属关系从[" + dt.Rows[0]["hr_subject"].ToString() + "]改为[" + data["hr_subject"] + "]";
                            else
                                memo += "；将隶属关系从[" + dt.Rows[0]["hr_subject"].ToString() + "]改为[" + data["hr_subject"] + "]";
                        }
                        if (!data["hr_business"].ToString().Equals(dt.Rows[0]["hr_business"].ToString()))
                        {
                            if (string.IsNullOrEmpty(memo))
                                memo = "HR协会会员：" + dt.Rows[0]["hr_company"].ToString() + "，将经营范围从[" + dt.Rows[0]["hr_business"].ToString() + "]改为[" + data["hr_business"] + "]";
                            else
                                memo += "；将经营范围从[" + dt.Rows[0]["hr_business"].ToString() + "]改为[" + data["hr_business"] + "]";
                        }
                        if (!data["hr_address"].ToString().Equals(dt.Rows[0]["hr_address"].ToString()))
                        {
                            if (string.IsNullOrEmpty(memo))
                                memo = "HR协会会员：" + dt.Rows[0]["hr_company"].ToString() + "，将通讯地址从[" + dt.Rows[0]["hr_address"].ToString() + "]改为[" + data["hr_address"] + "]";
                            else
                                memo += "；将通讯地址从[" + dt.Rows[0]["hr_address"].ToString() + "]改为[" + data["hr_address"] + "]";
                        }
                        if (!data["hr_memo"].ToString().Equals(dt.Rows[0]["hr_memo"].ToString()))
                        {
                            if (string.IsNullOrEmpty(memo))
                                memo = "HR协会会员：" + dt.Rows[0]["hr_company"].ToString() + "，将单位基本情况进行修改";
                            else
                                memo += "；将单位基本情况进行修改";
                        }
                        if (!data["hr_name"].ToString().Equals(dt.Rows[0]["hr_name"].ToString()))
                        {
                            if (string.IsNullOrEmpty(memo))
                                memo = "HR协会会员：" + dt.Rows[0]["hr_company"].ToString() + "，将会员代表姓名从[" + dt.Rows[0]["hr_name"].ToString() + "]改为[" + data["hr_name"] + "]";
                            else
                                memo += "；将会员代表姓名从[" + dt.Rows[0]["hr_name"].ToString() + "]改为[" + data["hr_name"] + "]";
                        }
                        //if (!data["di_state"].ToString().Equals(dt.Rows[0]["di_state"].ToString()))
                        //{
                        //    string s1 = "启用";
                        //    if (ConfigurationManager.AppSettings["StateDisable"].Equals(dt.Rows[0]["di_state"].ToString()))
                        //        s1 = "禁用";
                        //    string s2 = "启用";
                        //    if (ConfigurationManager.AppSettings["StateDisable"].Equals(data["di_state"].ToString()))
                        //        s2 = "禁用";
                        //    if (string.IsNullOrEmpty(memo))
                        //        memo = "系统字典：" + dt.Rows[0]["di_name"].ToString() + "，将状态从[" + s1 + "]改为[" + s2 + "]";
                        //    else
                        //        memo += "；将状态从[" + s1 + "]改为[" + s2 + "]";
                        //}
                        if (!data["hr_sex"].ToString().Equals(dt.Rows[0]["hr_sex"].ToString()))
                        {
                            string s1 = "男";
                            if (ConfigurationManager.AppSettings["StateEnable"].Equals(dt.Rows[0]["hr_sex"].ToString()))
                                s1 = "女";
                            string s2 = "男";
                            if (ConfigurationManager.AppSettings["StateEnable"].Equals(data["hr_sex"].ToString()))
                                s2 = "女";
                            if (string.IsNullOrEmpty(memo))
                                memo = "HR协会会员：" + dt.Rows[0]["hr_company"].ToString() + "，将性别从[" + s1 + "]改为[" + s2 + "]";
                            else
                                memo += "；将性别从[" + s1 + "]改为[" + s2 + "]";
                        }
                        if (!data["hr_nation"].ToString().Equals(dt.Rows[0]["hr_nation"].ToString()))
                        {
                            if (string.IsNullOrEmpty(memo))
                                memo = "HR协会会员：" + dt.Rows[0]["hr_company"].ToString() + "，将民族从[" + dt.Rows[0]["hr_nation"].ToString() + "]改为[" + data["hr_nation"] + "]";
                            else
                                memo += "；将民族从[" + dt.Rows[0]["hr_nation"].ToString() + "]改为[" + data["hr_nation"] + "]";
                        }
                        if (!data["hr_birth"].ToString().Equals(dt.Rows[0]["hr_birth"].ToString()))
                        {
                            if (string.IsNullOrEmpty(memo))
                                memo = "HR协会会员：" + dt.Rows[0]["hr_company"].ToString() + "，将出生年月从[" + dt.Rows[0]["hr_birth"].ToString() + "]改为[" + data["hr_birth"] + "]";
                            else
                                memo += "；将出生年月从[" + dt.Rows[0]["hr_birth"].ToString() + "]改为[" + data["hr_birth"] + "]";
                        }
                        if (!data["hr_birth"].ToString().Equals(dt.Rows[0]["hr_birth"].ToString()))
                        {
                            if (string.IsNullOrEmpty(memo))
                                memo = "HR协会会员：" + dt.Rows[0]["hr_company"].ToString() + "，将出生年月从[" + dt.Rows[0]["hr_birth"].ToString() + "]改为[" + data["hr_birth"] + "]";
                            else
                                memo += "；将出生年月从[" + dt.Rows[0]["hr_birth"].ToString() + "]改为[" + data["hr_birth"] + "]";
                        }
                        if (!data["hr_education"].ToString().Equals(dt.Rows[0]["hr_education"].ToString()))
                        {
                            MyCommand.CommandText = " select di_name from dictionary where di_code=@hr_education and di_type=4 ";
                            object obj = MyCommand.ExecuteScalar();
                            string power = "";
                            if (obj != null && !string.IsNullOrEmpty(obj.ToString()))
                                power = obj.ToString();
                            if (string.IsNullOrEmpty(memo))
                                memo = "HR协会会员：" + dt.Rows[0]["hr_company"].ToString() + "，将文化程度从[" + dt.Rows[0]["di_name"].ToString() + "]改为[" + power + "]";
                            else
                                memo += "；将文化程度从[" + dt.Rows[0]["di_name"].ToString() + "]改为[" + power + "]";
                        }
                        if (!data["hr_political"].ToString().Equals(dt.Rows[0]["hr_political"].ToString()))
                        {
                            if (string.IsNullOrEmpty(memo))
                                memo = "HR协会会员：" + dt.Rows[0]["hr_company"].ToString() + "，将政治面貌从[" + dt.Rows[0]["hr_political"].ToString() + "]改为[" + data["hr_political"] + "]";
                            else
                                memo += "；将政治面貌从[" + dt.Rows[0]["hr_political"].ToString() + "]改为[" + data["hr_political"] + "]";
                        }
                        if (!data["hr_phone"].ToString().Equals(dt.Rows[0]["hr_phone"].ToString()))
                        {
                            if (string.IsNullOrEmpty(memo))
                                memo = "HR协会会员：" + dt.Rows[0]["hr_company"].ToString() + "，将固定电话从[" + dt.Rows[0]["hr_phone"].ToString() + "]改为[" + data["hr_phone"] + "]";
                            else
                                memo += "；将固定电话从[" + dt.Rows[0]["hr_phone"].ToString() + "]改为[" + data["hr_phone"] + "]";
                        }
                        if (!data["hr_job"].ToString().Equals(dt.Rows[0]["hr_job"].ToString()))
                        {
                            if (string.IsNullOrEmpty(memo))
                                memo = "HR协会会员：" + dt.Rows[0]["hr_company"].ToString() + "，将职务从[" + dt.Rows[0]["hr_job"].ToString() + "]改为[" + data["hr_job"] + "]";
                            else
                                memo += "；将职务从[" + dt.Rows[0]["hr_job"].ToString() + "]改为[" + data["hr_job"] + "]";
                        }
                        if (!data["hr_technical"].ToString().Equals(dt.Rows[0]["hr_technical"].ToString()))
                        {
                            if (string.IsNullOrEmpty(memo))
                                memo = "HR协会会员：" + dt.Rows[0]["hr_company"].ToString() + "，将职称从[" + dt.Rows[0]["hr_technical"].ToString() + "]改为[" + data["hr_technical"] + "]";
                            else
                                memo += "；将职称从[" + dt.Rows[0]["hr_technical"].ToString() + "]改为[" + data["hr_technical"] + "]";
                        }
                        if (!data["hr_mobile"].ToString().Equals(dt.Rows[0]["hr_mobile"].ToString()))
                        {
                            if (string.IsNullOrEmpty(memo))
                                memo = "HR协会会员：" + dt.Rows[0]["hr_company"].ToString() + "，将手机从[" + dt.Rows[0]["hr_mobile"].ToString() + "]改为[" + data["hr_mobile"] + "]";
                            else
                                memo += "；将手机从[" + dt.Rows[0]["hr_mobile"].ToString() + "]改为[" + data["hr_mobile"] + "]";
                        }
                        if (!data["hr_qq"].ToString().Equals(dt.Rows[0]["hr_qq"].ToString()))
                        {
                            if (string.IsNullOrEmpty(memo))
                                memo = "HR协会会员：" + dt.Rows[0]["hr_company"].ToString() + "，将QQ从[" + dt.Rows[0]["hr_qq"].ToString() + "]改为[" + data["hr_qq"] + "]";
                            else
                                memo += "；将QQ从[" + dt.Rows[0]["hr_qq"].ToString() + "]改为[" + data["hr_qq"] + "]";
                        }
                        if (string.IsNullOrEmpty(memo))
                            memo = "HR协会会员：" + dt.Rows[0]["hr_company"].ToString() + "，未修改任何字段";
                        MyCommand.CommandText = " update hrmember set hr_company=@hr_company,hr_card=@hr_card,hr_address=@hr_address,hr_postcode=@hr_postcode,hr_tel=@hr_tel,hr_fax=@hr_fax,hr_type=@hr_type,hr_subject=@hr_subject,hr_business=@hr_business,hr_memo=@hr_memo,hr_name=@hr_name,hr_sex=@hr_sex,hr_nation=@hr_nation,hr_birth=@hr_birth,hr_education=@hr_education,hr_political=@hr_political,hr_job=@hr_job,hr_technical=@hr_technical,hr_phone=@hr_phone,hr_mobile=@hr_mobile,hr_qq=@hr_qq,hr_modifytime=getdate(),hr_modifyuser=@user,hr_modifyip=@ip where hr_no=@hr_no ";
                        res = MyCommand.ExecuteNonQuery();
                        if (res > 0)
                            WriteLog(data["user"].ToString(), 2, data["ip"].ToString(), "用户【" + data["name"].ToString() + "】，在HR协会会员管理功能中进行了数据修改操作，修改记录为【" + memo + "】。", MyCommand);
                    }
                    else
                        res = 0;
                }
                else
                    res = 2;
            }
            MyTrans.Commit();
        }
        catch
        {
            MyTrans.Rollback("Tran");
            res = -1;
        }
        Close();
        return res;
    }

    /// <summary>
    /// 删除HR协会会员
    /// </summary>
    /// <param name="uid"></param>
    /// <param name="name"></param>
    /// <param name="ip"></param>
    /// <param name="hr_no"></param>
    /// <returns></returns>
    public int DeleteMember(string uid, string name, string ip, string hr_no)
    {
        int res = 0;
        Open();
        SqlCommand MyCommand = MyConnection.CreateCommand();
        SqlTransaction MyTrans = MyConnection.BeginTransaction("Tran");
        MyCommand.Connection = MyConnection;
        MyCommand.Transaction = MyTrans;
        try
        {
            string[] id = hr_no.Split(',');
            for (int i = 0; i < id.Length; i++)
            {
                MyCommand.CommandText = " select * from hrmember where hr_no=@hr_no ";
                MyCommand.Parameters.Add("@hr_no", SqlDbType.BigInt).Value = id[i];
                DataTable dt = new DataTable();
                SqlDataAdapter da = new SqlDataAdapter(MyCommand);
                da.Fill(dt);
                if (dt != null && dt.Rows.Count > 0)
                {
                    string memo = "HR协会会员：" + dt.Rows[0]["hr_company"].ToString();
                    MyCommand.CommandText = "delete from hrmember where hr_no=@hr_no ";
                    res = MyCommand.ExecuteNonQuery();
                    if (res > 0)
                        WriteLog(uid, 3, ip, "用户【" + name + "】，在HR协会会员管理功能中进行了数据删除操作，删除记录为【" + memo + "】。", MyCommand);
                }
                MyCommand.Parameters.Clear();
            }
            MyTrans.Commit();
            res = 1;
        }
        catch (Exception ex)
        {
            MyTrans.Rollback("Tran");
            res = -1;
        }
        Close();
        return res;
    }

    /// <summary>
    /// 显示/隐藏HR协会会员
    /// </summary>
    /// <param name="uid"></param>
    /// <param name="name"></param>
    /// <param name="ip"></param>
    /// <param name="hr_no"></param>
    /// <param name="hr_hide"></param>
    /// <returns></returns>
    public int LockMember(string uid, string name, string ip, string hr_no, string hr_hide)
    {
        int res = 0;
        Open();
        SqlCommand MyCommand = MyConnection.CreateCommand();
        SqlTransaction MyTrans = MyConnection.BeginTransaction("Tran");
        MyCommand.Connection = MyConnection;
        MyCommand.Transaction = MyTrans;
        try
        {
            string[] id = hr_no.Split(',');
            for (int i = 0; i < id.Length; i++)
            {
                MyCommand.CommandText = " select * from hrmember where hr_no=@hr_no ";
                MyCommand.Parameters.Add("@hr_no", SqlDbType.BigInt).Value = id[i];
                DataTable dt = new DataTable();
                SqlDataAdapter da = new SqlDataAdapter(MyCommand);
                da.Fill(dt);
                if (dt != null && dt.Rows.Count > 0)
                {
                    string memo = "";
                    if (!hr_hide.Equals(dt.Rows[0]["hr_hide"].ToString()))
                    {
                        string s1 = "隐藏";
                        if (ConfigurationManager.AppSettings["Open"].Equals(dt.Rows[0]["hr_hide"].ToString()))
                            s1 = "显示";
                        string s2 = "隐藏";
                        if (ConfigurationManager.AppSettings["Open"].Equals(hr_hide))
                            s2 = "显示";
                        memo = "HR协会会员：" + dt.Rows[0]["hr_company"].ToString() + "，将状态从[" + s1 + "]改为[" + s2 + "]";
                    }
                    if (string.IsNullOrEmpty(memo))
                        memo = "HR协会会员：" + dt.Rows[0]["hr_company"].ToString() + "，未修改任何字段";
                    MyCommand.CommandText = "update hrmember set hr_hide=@hr_hide where hr_no=@hr_no ";
                    MyCommand.Parameters.Add("@hr_hide", SqlDbType.Int).Value = hr_hide;
                    res = MyCommand.ExecuteNonQuery();
                    if (res > 0)
                        WriteLog(uid, 2, ip, "用户【" + name + "】，在HR协会会员管理功能中进行了数据修改操作，修改记录为【" + memo + "】。", MyCommand);
                }
                MyCommand.Parameters.Clear();
            }
            MyTrans.Commit();
            res = 1;
        }
        catch (Exception ex)
        {
            MyTrans.Rollback("Tran");
            res = -1;
        }
        Close();
        return res;
    }

    /// <summary>
    /// 获取HR协会会员名称
    /// </summary>
    /// <param name="hr_no"></param>
    /// <returns></returns>
    public string GetHrName(string hr_no)
    {
        string res = "";
        Open();
        try
        {
            SqlCommand MyCommand = new SqlCommand("select hr_company from hrmember where hr_no=@hr_no", MyConnection);
            MyCommand.Parameters.Add("@hr_no", SqlDbType.BigInt).Value = hr_no;
            res = MyCommand.ExecuteScalar().ToString();
        }
        catch (Exception e)
        {

        }
        Close();
        return res;
    }

    /// <summary>
    /// 保存HR协会会员缴费记录
    /// </summary>
    /// <param name="data"></param>
    /// <returns></returns>
    public int SaveHrPay(Hashtable data)
    {
        int res;
        Open();
        SqlCommand MyCommand = MyConnection.CreateCommand();
        SqlTransaction MyTrans;
        MyTrans = MyConnection.BeginTransaction("Tran");
        MyCommand.Connection = MyConnection;
        MyCommand.Transaction = MyTrans;
        try
        {
            MyCommand.Parameters.Add("@hp_hrno", SqlDbType.BigInt).Value = data["hp_hrno"];
            MyCommand.Parameters.Add("@hp_money", SqlDbType.Decimal).Value = data["hp_money"];
            MyCommand.Parameters.Add("@hp_memo", SqlDbType.NText).Value = data["hp_memo"];
            MyCommand.Parameters.Add("@user", SqlDbType.NVarChar).Value = data["user"];
            MyCommand.Parameters.Add("@ip", SqlDbType.NVarChar).Value = data["ip"];

            MyCommand.CommandText = " select * from hrmember where hr_no=@hp_hrno ";
            DataTable dt = new DataTable();
            SqlDataAdapter da = new SqlDataAdapter(MyCommand);
            da.Fill(dt);
            if (dt != null && dt.Rows.Count > 0)
            {
                MyCommand.CommandText = " insert into hrpayment (hp_hrno,hp_money,hp_memo,hp_inserttime,hp_insertuser,hp_insertip) values (@hp_hrno,@hp_money,@hp_memo,getdate(),@user,@ip) ";
                res = MyCommand.ExecuteNonQuery();
                if (res > 0)
                    WriteLog(data["user"].ToString(), 1, data["ip"].ToString(), "用户【" + data["name"].ToString() + "】，在HR协会会员管理功能中进行了缴费新增操作，新增记录为【单位名称：" + data["hr_company"] + "，费用：" + data["hp_money"] + "，备注：" + data["hp_memo"] + "】。", MyCommand);
                else
                    res = -1;
            }
            else
                res = 0;
            MyTrans.Commit();
        }
        catch
        {
            MyTrans.Rollback("Tran");
            res = -1;
        }
        Close();
        return res;
    }

    /// <summary>
    /// 删除HR协会会员缴费记录
    /// </summary>
    /// <param name="uid"></param>
    /// <param name="name"></param>
    /// <param name="ip"></param>
    /// <param name="hp_no"></param>
    /// <returns></returns>
    public int DeleteHrPay(string uid, string name, string ip, string hp_no)
    {
        int res = 0;
        Open();
        SqlCommand MyCommand = MyConnection.CreateCommand();
        SqlTransaction MyTrans = MyConnection.BeginTransaction("Tran");
        MyCommand.Connection = MyConnection;
        MyCommand.Transaction = MyTrans;
        try
        {
            string[] id = hp_no.Split(',');
            for (int i = 0; i < id.Length; i++)
            {
                MyCommand.CommandText = " select * from hrpayment left join hrmember on hp_hrno=hr_no where hp_no=@hp_no ";
                MyCommand.Parameters.Add("@hp_no", SqlDbType.BigInt).Value = id[i];
                DataTable dt = new DataTable();
                SqlDataAdapter da = new SqlDataAdapter(MyCommand);
                da.Fill(dt);
                if (dt != null && dt.Rows.Count > 0)
                {
                    string memo = "HR协会会员：" + dt.Rows[0]["hr_company"].ToString() + "，" + dt.Rows[0]["hp_inserttime"].ToString() + "添加的费用[" + dt.Rows[0]["hp_money"].ToString() + "]";
                    MyCommand.CommandText = "delete from hrpayment where hp_no=@hp_no ";
                    res = MyCommand.ExecuteNonQuery();
                    if (res > 0)
                        WriteLog(uid, 3, ip, "用户【" + name + "】，在HR协会缴费记录管理功能中进行了缴费记录删除操作，删除记录为【" + memo + "】。", MyCommand);
                }
                MyCommand.Parameters.Clear();
            }
            MyTrans.Commit();
            res = 1;
        }
        catch (Exception ex)
        {
            MyTrans.Rollback("Tran");
            res = -1;
        }
        Close();
        return res;
    }

    /// <summary>
    /// 获取咨询
    /// </summary>
    /// <param name="cs_no"></param>
    /// <returns></returns>
    public Hashtable GetConsult(string cs_no)
    {
        Open();
        SqlCommand MyCommand = new SqlCommand();
        MyCommand.Connection = MyConnection;
        MyCommand.CommandText = "select * from consult where cs_no=@cs_no";
        MyCommand.Parameters.Add("@cs_no", SqlDbType.BigInt).Value = cs_no;
        DataTable data = new DataTable();
        SqlDataAdapter adapter = new SqlDataAdapter(MyCommand);
        adapter.Fill(data);
        Close();
        ArrayList da = DataTable2ArrayList(data);
        return da.Count > 0 ? (Hashtable)da[0] : null;
    }

    /// <summary>
    /// 回复咨询
    /// </summary>
    /// <param name="data"></param>
    /// <returns></returns>
    public int SaveConsult(Hashtable data)
    {
        int res;
        Open();
        SqlCommand MyCommand = MyConnection.CreateCommand();
        SqlTransaction MyTrans;
        MyTrans = MyConnection.BeginTransaction("Tran");
        MyCommand.Connection = MyConnection;
        MyCommand.Transaction = MyTrans;
        try
        {
            MyCommand.Parameters.Add("@cs_no", SqlDbType.BigInt).Value = data["cs_no"];
            MyCommand.Parameters.Add("@cs_hfcontent", SqlDbType.NText).Value = data["cs_hfcontent"];
            MyCommand.Parameters.Add("@user", SqlDbType.NVarChar).Value = data["user"];
            MyCommand.Parameters.Add("@ip", SqlDbType.NVarChar).Value = data["ip"];

            MyCommand.CommandText = " select * from consult where cs_no=@cs_no ";
            DataTable dt = new DataTable();
            SqlDataAdapter da = new SqlDataAdapter(MyCommand);
            da.Fill(dt);
            if (dt != null && dt.Rows.Count > 0)
            {
                string memo = "";
                if (!data["cs_hfcontent"].ToString().Equals(dt.Rows[0]["cs_hfcontent"].ToString()))
                    memo = "咨询：咨询人【" + dt.Rows[0]["cs_asker"].ToString() + "】，提问时间【" + dt.Rows[0]["cs_asktime"].ToString() + "】，将回复内容从[" + dt.Rows[0]["cs_hfcontent"].ToString() + "]改为[" + data["cs_hfcontent"] + "]";
                if (string.IsNullOrEmpty(memo))
                    memo = "咨询：咨询人【" + dt.Rows[0]["cs_asker"].ToString() + "】，提问时间【" + dt.Rows[0]["cs_asktime"].ToString() + "】，未修改任何字段";
                MyCommand.CommandText = " update consult set cs_hfcontent=@cs_hfcontent,cs_hftime=getdate() where cs_no=@cs_no ";
                res = MyCommand.ExecuteNonQuery();
                if (res > 0)
                    WriteLog(data["user"].ToString(), 2, data["ip"].ToString(), "用户【" + data["name"].ToString() + "】，在咨询管理功能中进行了回复操作，回复记录为【" + memo + "】。", MyCommand);
            }
            else
                res = 0;

            MyTrans.Commit();
        }
        catch
        {
            MyTrans.Rollback("Tran");
            res = -1;
        }
        Close();
        return res;
    }

    /// <summary>
    /// 删除咨询
    /// </summary>
    /// <param name="uid"></param>
    /// <param name="name"></param>
    /// <param name="ip"></param>
    /// <param name="cs_no"></param>
    /// <returns></returns>
    public int DeleteConsult(string uid, string name, string ip, string cs_no)
    {
        int res = 0;
        Open();
        SqlCommand MyCommand = MyConnection.CreateCommand();
        SqlTransaction MyTrans = MyConnection.BeginTransaction("Tran");
        MyCommand.Connection = MyConnection;
        MyCommand.Transaction = MyTrans;
        try
        {
            string[] id = cs_no.Split(',');
            for (int i = 0; i < id.Length; i++)
            {
                MyCommand.CommandText = " select * from consult where cs_no=@cs_no ";
                MyCommand.Parameters.Add("@cs_no", SqlDbType.BigInt).Value = id[i];
                DataTable dt = new DataTable();
                SqlDataAdapter da = new SqlDataAdapter(MyCommand);
                da.Fill(dt);
                if (dt != null && dt.Rows.Count > 0)
                {
                    string memo = memo = "咨询：咨询人【" + dt.Rows[0]["cs_asker"].ToString() + "】，提问时间【" + dt.Rows[0]["cs_asktime"].ToString() + "】";
                    MyCommand.CommandText = "delete from consult where cs_no=@cs_no ";
                    res = MyCommand.ExecuteNonQuery();
                    if (res > 0)
                        WriteLog(uid, 3, ip, "用户【" + name + "】，在咨询管理功能中进行了咨询删除操作，删除记录为【" + memo + "】。", MyCommand);
                }
                MyCommand.Parameters.Clear();
            }
            MyTrans.Commit();
            res = 1;
        }
        catch (Exception ex)
        {
            MyTrans.Rollback("Tran");
            res = -1;
        }
        Close();
        return res;
    }

    /// <summary>
    /// 根据状态获取角色
    /// </summary>
    /// <param name="ac_state"></param>
    /// <returns></returns>
    public DataTable GetActorByState(int ac_state)
    {
        Open();
        SqlCommand MyCommand = new SqlCommand();
        MyCommand.Connection = MyConnection;

        MyCommand.CommandText = "select * from actor where ac_state=@ac_state ";
        MyCommand.Parameters.Add("@ac_state", SqlDbType.Int).Value = ac_state;
        DataTable data = new DataTable();
        SqlDataAdapter adapter = new SqlDataAdapter(MyCommand);
        adapter.Fill(data);
        Close();
        return (data);
    }

    /// <summary>
    /// 获取角色
    /// </summary>
    /// <param name="ac_no"></param>
    /// <returns></returns>
    public Hashtable GetActor(string ac_no)
    {
        Open();
        SqlCommand MyCommand = new SqlCommand();
        MyCommand.Connection = MyConnection;

        MyCommand.CommandText = "select * from actor where ac_no=@ac_no";
        MyCommand.Parameters.Add("@ac_no", SqlDbType.BigInt).Value = ac_no;
        DataTable data = new DataTable();
        SqlDataAdapter adapter = new SqlDataAdapter(MyCommand);
        adapter.Fill(data);
        Close();
        ArrayList da = DataTable2ArrayList(data);
        return da.Count > 0 ? (Hashtable)da[0] : null;
    }

    /// <summary>
    /// 保存角色
    /// </summary>
    /// <param name="data"></param>
    /// <returns></returns>
    public int SaveActor(Hashtable data)
    {
        int res = 0;
        Open();
        SqlCommand MyCommand = MyConnection.CreateCommand();
        SqlTransaction MyTrans;
        MyTrans = MyConnection.BeginTransaction("Tran");
        MyCommand.Connection = MyConnection;
        MyCommand.Transaction = MyTrans;
        try
        {
            MyCommand.Parameters.Add("@ac_name", SqlDbType.NVarChar).Value = data["ac_name"];
            MyCommand.Parameters.Add("@ac_state", SqlDbType.Int).Value = data["ac_state"];
            MyCommand.Parameters.Add("@ac_mlno", SqlDbType.NVarChar).Value = data["ac_mlno"];
            MyCommand.Parameters.Add("@user", SqlDbType.NVarChar).Value = data["user"];
            MyCommand.Parameters.Add("@ip", SqlDbType.NVarChar).Value = data["ip"];
            if (string.IsNullOrEmpty(data["ac_no"].ToString()))
            {
                MyCommand.CommandText = " insert into actor (ac_name,ac_state,ac_inserttime,ac_insertuser,ac_insertip) values (@ac_name,@ac_state,getdate(),@user,@ip);select @@Identity";
                object o = MyCommand.ExecuteScalar();
                Int64 ret = 0;
                if (o != null && o.ToString() != "")
                    ret = Int64.Parse(o.ToString());
                else
                {
                    MyTrans.Rollback("Tran");
                    Close();
                    return -1;
                }
                if (ret > 0)
                {
                    MyCommand.CommandText = "insert into actorpower select @ap_acno,ml_no,ml_pid from menulist where ml_no in (" + data["ac_mlno"] + ")";
                    MyCommand.Parameters.Add("@ap_acno", SqlDbType.BigInt).Value = ret;
                    res = MyCommand.ExecuteNonQuery();
                    if (res > 0)
                        WriteLog(data["user"].ToString(), 1, data["ip"].ToString(), "用户【" + data["name"].ToString() + "】，在角色权限管理功能中进行了数据新增操作，新增记录为【名称：" + data["ac_name"] + "，状态：" + (ConfigurationManager.AppSettings["StateEnable"].Equals(data["ac_state"]) ? "启用" : "禁用") + "】。", MyCommand);
                }
                else
                {
                    MyTrans.Rollback("Tran");
                    Close();
                    return -1;
                }
            }
            else
            {
                MyCommand.CommandText = " select * from actor where ac_no=@ac_no ";
                MyCommand.Parameters.Add("@ac_no", SqlDbType.BigInt).Value = data["ac_no"];
                DataTable dt = new DataTable();
                SqlDataAdapter da = new SqlDataAdapter(MyCommand);
                da.Fill(dt);
                string memo = "";
                if (dt != null && dt.Rows.Count > 0)
                {
                    if (!data["ac_name"].ToString().Equals(dt.Rows[0]["ac_name"].ToString()))
                        memo = "角色：" + dt.Rows[0]["ac_name"].ToString() + "，将名称从[" + dt.Rows[0]["ac_name"].ToString() + "]改为[" + data["ac_name"].ToString() + "]";
                    if (!data["ac_state"].ToString().Equals(dt.Rows[0]["ac_state"].ToString()))
                    {
                        string s1 = "启用";
                        if (ConfigurationManager.AppSettings["StateDisable"].Equals(dt.Rows[0]["ac_state"].ToString()))
                            s1 = "禁用";
                        string s2 = "启用";
                        if (ConfigurationManager.AppSettings["StateDisable"].Equals(data["ac_state"].ToString()))
                            s2 = "禁用";
                        if (string.IsNullOrEmpty(memo))
                            memo = "角色：" + dt.Rows[0]["ac_name"].ToString() + "，将状态从[" + s1 + "]改为[" + s2 + "]";
                        else
                            memo += "；将状态从[" + s1 + "]改为[" + s2 + "]";
                    }
                    MyCommand.CommandText = " update actor set ac_name=@ac_name,ac_state=@ac_state,ac_modifytime=getdate(),ac_modifyuser=@user,ac_modifyip=@ip where ac_no=@ac_no ";
                    res = MyCommand.ExecuteNonQuery();
                    if (res > 0)
                    {
                        MyCommand.CommandText = "delete from actorpower where ap_acno=@ap_acno";
                        MyCommand.Parameters.Add("@ap_acno", SqlDbType.BigInt).Value = data["ac_no"];
                        MyCommand.ExecuteNonQuery();
                        MyCommand.CommandText = "insert into actorpower select @ap_acno,ml_no,ml_pid from menulist where ml_no in (" + data["ac_mlno"] + ")";
                        MyCommand.ExecuteNonQuery();
                        WriteLog(data["user"].ToString(), 2, data["ip"].ToString(), "用户【" + data["name"].ToString() + "】，在角色权限管理功能中进行了数据修改操作，修改记录为【" + memo + "】。", MyCommand);
                    }
                }
            }
            MyTrans.Commit();
        }
        catch
        {
            MyTrans.Rollback("Tran");
            res = -1;
        }
        Close();
        return res;
    }

    /// <summary>
    /// 删除角色
    /// </summary>
    /// <param name="uid"></param>
    /// <param name="name"></param>
    /// <param name="ip"></param>
    /// <param name="ac_no"></param>
    /// <returns></returns>
    public int DeleteActor(string uid, string name, string ip, string ac_no)
    {
        int res = 0;
        Open();
        SqlCommand MyCommand = MyConnection.CreateCommand();
        SqlTransaction MyTrans = MyConnection.BeginTransaction("Tran");
        MyCommand.Connection = MyConnection;
        MyCommand.Transaction = MyTrans;
        try
        {
            string[] id = ac_no.Split(',');
            for (int i = 0; i < id.Length; i++)
            {
                MyCommand.CommandText = " select * from actor where ac_no=@ac_no ";
                MyCommand.Parameters.Add("@ac_no", SqlDbType.BigInt).Value = id[i];
                DataTable dt = new DataTable();
                SqlDataAdapter da = new SqlDataAdapter(MyCommand);
                da.Fill(dt);
                if (dt != null && dt.Rows.Count > 0)
                {
                    string memo = "角色：" + dt.Rows[0]["ac_name"].ToString();
                    MyCommand.CommandText = "delete from actor where ac_no=@ac_no ";
                    res = MyCommand.ExecuteNonQuery();

                    MyCommand.CommandText = " delete from actorpower where ap_acno=@ac_no ";
                    MyCommand.ExecuteNonQuery();
                    if (res > 0)
                        WriteLog(uid, 3, ip, "用户【" + name + "】，在角色权限管理功能中进行了数据删除操作，删除记录为【" + memo + "】。", MyCommand);
                }
                MyCommand.Parameters.Clear();
            }
            MyTrans.Commit();
            res = 1;
        }
        catch (Exception ex)
        {
            MyTrans.Rollback("Tran");
            res = -1;
        }
        Close();
        return res;
    }

    /// <summary>
    /// 
    /// </summary>
    /// <param name="su_no"></param>
    /// <returns></returns>
    public Hashtable GetUser(string su_no)
    {
        Open();
        SqlCommand MyCommand = new SqlCommand();
        MyCommand.Connection = MyConnection;

        MyCommand.CommandText = "select * from systemuser left join actor on su_power=ac_no where su_no=@su_no";
        MyCommand.Parameters.Add("@su_no", SqlDbType.BigInt).Value = su_no;
        DataTable data = new DataTable();
        SqlDataAdapter adapter = new SqlDataAdapter(MyCommand);
        adapter.Fill(data);
        Close();
        ArrayList da = DataTable2ArrayList(data);
        return da.Count > 0 ? (Hashtable)da[0] : null;
    }

    public int SaveUser(Hashtable data)
    {
        int res;
        Open();
        SqlCommand MyCommand = MyConnection.CreateCommand();
        SqlTransaction MyTrans;
        MyTrans = MyConnection.BeginTransaction("Tran");
        MyCommand.Connection = MyConnection;
        MyCommand.Transaction = MyTrans;
        try
        {
            MyCommand.Parameters.Add("@su_name", SqlDbType.NVarChar).Value = data["su_name"];
            MyCommand.Parameters.Add("@su_power", SqlDbType.BigInt).Value = data["su_power"];
            MyCommand.Parameters.Add("@su_login", SqlDbType.NVarChar).Value = data["su_login"];
            MyCommand.Parameters.Add("@su_tel", SqlDbType.NVarChar).Value = data["su_tel"];
            MyCommand.Parameters.Add("@su_state", SqlDbType.Int).Value = data["su_state"];
            MyCommand.Parameters.Add("@user", SqlDbType.NVarChar).Value = data["user"];
            MyCommand.Parameters.Add("@ip", SqlDbType.NVarChar).Value = data["ip"];
            if (string.IsNullOrEmpty(data["su_no"].ToString()))
            {
                MyCommand.CommandText = " select count(1) from systemuser where su_name=@su_name";
                int count = Convert.ToInt32(MyCommand.ExecuteScalar());
                if (count == 0)
                {
                    MyCommand.CommandText = " select ac_name from actor where ac_no=@su_power ";
                    object obj = MyCommand.ExecuteScalar();
                    string power = "";
                    if (obj != null && !string.IsNullOrEmpty(obj.ToString()))
                        power = obj.ToString();
                    MyCommand.CommandText = " insert into systemuser (su_login,su_pwd,su_power,su_state,su_name,su_tel,su_inserttime,su_insertip,su_insertuser,su_loginnum) values (@su_login,@su_pwd,@su_power,@su_state,@su_name,@su_tel,getdate(),@ip,@user,0) ";
                    MyCommand.Parameters.Add("@su_pwd", SqlDbType.NVarChar).Value = FormsAuthentication.HashPasswordForStoringInConfigFile("888888", "MD5").ToLower();
                    res = MyCommand.ExecuteNonQuery();
                    if (res > 0)
                        WriteLog(data["user"].ToString(), 1, data["ip"].ToString(), "用户【" + data["name"].ToString() + "】，在管理员账户管理功能中进行了数据新增操作，新增记录为【用户名：" + data["su_login"] + "，真实姓名：" + data["su_name"] + (!string.IsNullOrEmpty(data["su_tel"].ToString()) ? "，联系电话：" + data["su_tel"] : "") + "，角色：" + power + "，状态：" + (ConfigurationManager.AppSettings["StateEnable"].Equals(data["ac_state"]) ? "启用" : "禁用") + "】。", MyCommand);
                    else
                        res = -1;
                }
                else
                    res = 2;
            }
            else
            {
                MyCommand.CommandText = " select * from systemuser left join actor on su_power=ac_no where su_no=@su_no ";
                MyCommand.Parameters.Add("@su_no", SqlDbType.BigInt).Value = data["su_no"];
                DataTable dt = new DataTable();
                SqlDataAdapter da = new SqlDataAdapter(MyCommand);
                da.Fill(dt);
                if (dt != null && dt.Rows.Count > 0)
                {
                    string memo = "";
                    if (!data["su_name"].ToString().Equals(dt.Rows[0]["su_name"].ToString()))
                        memo = "用户：" + dt.Rows[0]["su_login"].ToString() + "，将真实姓名从[" + dt.Rows[0]["su_name"].ToString() + "]改为[" + data["su_name"] + "]";
                    if (!data["su_tel"].ToString().Equals(dt.Rows[0]["su_tel"].ToString()))
                    {
                        if (string.IsNullOrEmpty(memo))
                            memo = "用户：" + dt.Rows[0]["su_login"].ToString() + "，将联系电话从[" + dt.Rows[0]["su_tel"].ToString() + "]改为[" + data["su_tel"] + "]";
                        else
                            memo += "；将联系电话从[" + dt.Rows[0]["su_tel"].ToString() + "]改为[" + data["su_tel"] + "]";
                    }

                    if (!data["su_power"].ToString().Equals(dt.Rows[0]["su_power"].ToString()))
                    {
                        MyCommand.CommandText = " select ac_name from actor where ac_no=@su_power ";
                        object obj = MyCommand.ExecuteScalar();
                        string power = "";
                        if (obj != null && !string.IsNullOrEmpty(obj.ToString()))
                            power = obj.ToString();
                        if (string.IsNullOrEmpty(memo))
                            memo = "用户：" + dt.Rows[0]["su_login"].ToString() + "，将角色从[" + dt.Rows[0]["ac_name"].ToString() + "]改为[" + power + "]";
                        else
                            memo += "；将角色从[" + dt.Rows[0]["ac_name"].ToString() + "]改为[" + power + "]";
                    }
                    if (!data["su_state"].ToString().Equals(dt.Rows[0]["su_state"].ToString()))
                    {
                        string s1 = "启用";
                        if (ConfigurationManager.AppSettings["StateDisable"].Equals(dt.Rows[0]["su_state"].ToString()))
                            s1 = "禁用";
                        string s2 = "启用";
                        if (ConfigurationManager.AppSettings["StateDisable"].Equals(data["su_state"].ToString()))
                            s2 = "禁用";
                        if (string.IsNullOrEmpty(memo))
                            memo = "用户：" + dt.Rows[0]["su_login"].ToString() + "，将状态从[" + s1 + "]改为[" + s2 + "]";
                        else
                            memo += "；将状态从[" + s1 + "]改为[" + s2 + "]";
                    }
                    if (string.IsNullOrEmpty(memo))
                        memo = "用户：" + dt.Rows[0]["su_login"].ToString() + "，未修改任何字段";
                    MyCommand.CommandText = " update systemuser set su_login=@su_login,su_power=@su_power,su_state=@su_state,su_name=@su_name,su_tel=@su_tel,su_modifytime=getdate(),su_modifyip=@ip,su_modifyuser=@user where su_no=@su_no ";
                    res = MyCommand.ExecuteNonQuery();
                    if (res > 0)
                        WriteLog(data["user"].ToString(), 2, data["ip"].ToString(), "用户【" + data["name"].ToString() + "】，在管理员账户管理功能中进行了数据修改操作，修改记录为【" + memo + "】。", MyCommand);
                }
                else
                    res = 0;
            }
            MyTrans.Commit();
        }
        catch
        {
            MyTrans.Rollback("Tran");
            res = -1;
        }
        Close();
        return res;
    }

    public int DeleteUser(string uid, string name, string ip, string su_no)
    {
        int res = 0;
        Open();
        SqlCommand MyCommand = MyConnection.CreateCommand();
        SqlTransaction MyTrans = MyConnection.BeginTransaction("Tran");
        MyCommand.Connection = MyConnection;
        MyCommand.Transaction = MyTrans;
        try
        {
            string[] id = su_no.Split(',');
            for (int i = 0; i < id.Length; i++)
            {
                MyCommand.CommandText = " select * from systemuser where su_no=@su_no ";
                MyCommand.Parameters.Add("@su_no", SqlDbType.BigInt).Value = id[i];
                DataTable dt = new DataTable();
                SqlDataAdapter da = new SqlDataAdapter(MyCommand);
                da.Fill(dt);
                if (dt != null && dt.Rows.Count > 0)
                {
                    string memo = "用户：" + dt.Rows[0]["su_login"].ToString();
                    MyCommand.CommandText = "delete from systemuser where su_no=@su_no ";
                    res = MyCommand.ExecuteNonQuery();
                    if (res > 0)
                        WriteLog(uid, 3, ip, "用户【" + name + "】，在管理员账户管理功能中进行了数据删除操作，删除记录为【" + memo + "】。", MyCommand);
                }
                MyCommand.Parameters.Clear();
            }
            MyTrans.Commit();
            res = 1;
        }
        catch (Exception ex)
        {
            MyTrans.Rollback("Tran");
            res = -1;
        }
        Close();
        return res;
    }

    public int LockUser(string uid, string name, string ip, string su_no, string su_state)
    {
        int res = 0;
        Open();
        SqlCommand MyCommand = MyConnection.CreateCommand();
        SqlTransaction MyTrans = MyConnection.BeginTransaction("Tran");
        MyCommand.Connection = MyConnection;
        MyCommand.Transaction = MyTrans;
        try
        {
            string[] id = su_no.Split(',');
            for (int i = 0; i < id.Length; i++)
            {
                MyCommand.CommandText = " select * from systemuser where su_no=@su_no ";
                MyCommand.Parameters.Add("@su_no", SqlDbType.BigInt).Value = id[i];
                DataTable dt = new DataTable();
                SqlDataAdapter da = new SqlDataAdapter(MyCommand);
                da.Fill(dt);
                if (dt != null && dt.Rows.Count > 0)
                {
                    string memo = "";
                    if (!su_state.Equals(dt.Rows[0]["su_state"].ToString()))
                    {
                        string s1 = "启用";
                        if (ConfigurationManager.AppSettings["StateDisable"].Equals(dt.Rows[0]["su_state"].ToString()))
                            s1 = "禁用";
                        string s2 = "启用";
                        if (ConfigurationManager.AppSettings["StateDisable"].Equals(su_state))
                            s2 = "禁用";
                        memo = "用户：" + dt.Rows[0]["su_login"].ToString() + "，将状态从[" + s1 + "]改为[" + s2 + "]";
                    }
                    if (string.IsNullOrEmpty(memo))
                        memo = "用户：" + dt.Rows[0]["su_login"].ToString() + "，未修改任何字段";
                    MyCommand.CommandText = "update systemuser set su_state=@su_state where su_no=@su_no ";
                    MyCommand.Parameters.Add("@su_state", SqlDbType.Int).Value = su_state;
                    res = MyCommand.ExecuteNonQuery();
                    if (res > 0)
                        WriteLog(uid, 2, ip, "用户【" + name + "】，在管理员账户管理功能中进行了数据修改操作，修改记录为【" + memo + "】。", MyCommand);
                }
                MyCommand.Parameters.Clear();
            }
            MyTrans.Commit();
            res = 1;
        }
        catch (Exception ex)
        {
            MyTrans.Rollback("Tran");
            res = -1;
        }
        Close();
        return res;
    }

    public Hashtable GetJobType(string jt_no)
    {
        Open();
        SqlCommand MyCommand = new SqlCommand();
        MyCommand.Connection = MyConnection;

        MyCommand.CommandText = "select * from jobtype where jt_no=@jt_no";
        MyCommand.Parameters.Add("@jt_no", SqlDbType.BigInt).Value = jt_no;
        DataTable data = new DataTable();
        SqlDataAdapter adapter = new SqlDataAdapter(MyCommand);
        adapter.Fill(data);
        Close();
        ArrayList da = DataTable2ArrayList(data);
        return da.Count > 0 ? (Hashtable)da[0] : null;
    }

    public DataTable GetJobTypeByStateP(int jt_state)
    {
        Open();
        SqlCommand MyCommand = new SqlCommand();
        MyCommand.Connection = MyConnection;

        MyCommand.CommandText = "select * from jobtype where jt_pid='0' and jt_state=@jt_state ";
        MyCommand.Parameters.Add("@jt_state", SqlDbType.Int).Value = jt_state;
        DataTable data = new DataTable();
        SqlDataAdapter adapter = new SqlDataAdapter(MyCommand);
        adapter.Fill(data);
        Close();
        return (data);
    }

    public DataTable GetJobTypeByP(string jt_pid, int jt_state)
    {
        Open();
        SqlCommand MyCommand = new SqlCommand();
        MyCommand.Connection = MyConnection;

        MyCommand.CommandText = "select * from jobtype where jt_pid<>'0' and jt_pid=@jt_pid and jt_state=@jt_state ";
        MyCommand.Parameters.Add("@jt_pid", SqlDbType.NVarChar).Value = jt_pid;
        MyCommand.Parameters.Add("@jt_state", SqlDbType.Int).Value = jt_state;
        DataTable data = new DataTable();
        SqlDataAdapter adapter = new SqlDataAdapter(MyCommand);
        adapter.Fill(data);
        Close();
        return (data);
    }

    public int SaveJobType(Hashtable data)
    {
        int res;
        Open();
        SqlCommand MyCommand = MyConnection.CreateCommand();
        SqlTransaction MyTrans;
        MyTrans = MyConnection.BeginTransaction("Tran");
        MyCommand.Connection = MyConnection;
        MyCommand.Transaction = MyTrans;
        try
        {
            MyCommand.Parameters.Add("@jt_name", SqlDbType.NVarChar).Value = data["jt_name"];
            MyCommand.Parameters.Add("@jt_id", SqlDbType.NVarChar).Value = data["jt_id"];
            MyCommand.Parameters.Add("@jt_pid", SqlDbType.NVarChar).Value = data["jt_pid"];
            MyCommand.Parameters.Add("@jt_state", SqlDbType.Int).Value = data["jt_state"];
            MyCommand.Parameters.Add("@jt_newid", SqlDbType.NVarChar).Value = data["jt_newid"];
            if (string.IsNullOrEmpty(data["jt_no"].ToString()))
            {
                MyCommand.CommandText = " select count(1) from jobtype where jt_name=@jt_name or jt_id=@jt_id ";
                int count = Convert.ToInt32(MyCommand.ExecuteScalar());
                if (count == 0)
                {
                    MyCommand.CommandText = " select jt_name from jobtype where jt_id=@jt_pid ";
                    object obj = MyCommand.ExecuteScalar();
                    string pid = "无";
                    if (obj != null && !string.IsNullOrEmpty(obj.ToString()))
                        pid = obj.ToString();
                    MyCommand.CommandText = " insert into jobtype (jt_name,jt_id,jt_pid,jt_state,jt_newid) values (@jt_name,@jt_id,@jt_pid,@jt_state,@jt_newid) ";
                    res = MyCommand.ExecuteNonQuery();
                    if (res > 0)
                        WriteLog(data["user"].ToString(), 1, data["ip"].ToString(), "用户【" + data["name"].ToString() + "】，在岗位类别设置功能中进行了数据新增操作，新增记录为【岗位名称：" + data["jt_name"] + "，父类：" + pid + "，岗位编号：" + data["jt_id"] + "，对应长三角编号：" + data["jt_newid"] + "，状态：" + (ConfigurationManager.AppSettings["StateEnable"].Equals(data["jt_state"]) ? "启用" : "禁用") + "】。", MyCommand);
                    else
                        res = -1;
                }
                else
                    res = 2;
            }
            else
            {
                MyCommand.CommandText = " select count(1) from jobtype where jt_no<>@jt_no and (jt_name=@jt_name or jt_id=@jt_id) ";
                MyCommand.Parameters.Add("@jt_no", SqlDbType.BigInt).Value = data["jt_no"];
                int count = Convert.ToInt32(MyCommand.ExecuteScalar());
                if (count == 0)
                {
                    MyCommand.CommandText = " select t1.*,case when t2.jt_name IS NULL then '无' end as pname from jobtype t1 left join jobtype t2 on t1.jt_pid = t2.jt_id where t1.jt_no=@jt_no ";
                    DataTable dt = new DataTable();
                    SqlDataAdapter da = new SqlDataAdapter(MyCommand);
                    da.Fill(dt);
                    if (dt != null && dt.Rows.Count > 0)
                    {
                        string memo = "";
                        if (!data["jt_name"].ToString().Equals(dt.Rows[0]["jt_name"].ToString()))
                            memo = "岗位：" + dt.Rows[0]["jt_name"].ToString() + "，将岗位名称从[" + dt.Rows[0]["jt_name"].ToString() + "]改为[" + data["jt_name"] + "]";
                        if (!data["jt_pid"].ToString().Equals(dt.Rows[0]["jt_pid"].ToString()))
                        {
                            MyCommand.CommandText = " select jt_name from jobtype where jt_id=@jt_pid ";
                            object obj = MyCommand.ExecuteScalar();
                            string pid = "无";
                            if (obj != null && !string.IsNullOrEmpty(obj.ToString()))
                                pid = obj.ToString();
                            if (string.IsNullOrEmpty(memo))
                                memo = "岗位：" + dt.Rows[0]["jt_name"].ToString() + "，将父类从[" + dt.Rows[0]["pname"].ToString() + "]改为[" + pid + "]";
                            else
                                memo += "；将父类从[" + dt.Rows[0]["pname"].ToString() + "]改为[" + pid + "]";
                        }
                        if (!data["jt_id"].ToString().Equals(dt.Rows[0]["jt_id"].ToString()))
                        {
                            if (string.IsNullOrEmpty(memo))
                                memo = "岗位：" + dt.Rows[0]["jt_name"].ToString() + "，将岗位编号从[" + dt.Rows[0]["jt_id"].ToString() + "]改为[" + data["jt_id"] + "]";
                            else
                                memo += "；将岗位编号从[" + dt.Rows[0]["jt_id"].ToString() + "]改为[" + data["jt_id"] + "]";
                        }
                        if (!data["jt_state"].ToString().Equals(dt.Rows[0]["jt_state"].ToString()))
                        {
                            string s1 = "启用";
                            if (ConfigurationManager.AppSettings["StateDisable"].Equals(dt.Rows[0]["jt_state"].ToString()))
                                s1 = "禁用";
                            string s2 = "启用";
                            if (ConfigurationManager.AppSettings["StateDisable"].Equals(data["jt_state"].ToString()))
                                s2 = "禁用";
                            if (string.IsNullOrEmpty(memo))
                                memo = "岗位：" + dt.Rows[0]["jt_name"].ToString() + "，将状态从[" + s1 + "]改为[" + s2 + "]";
                            else
                                memo += "；将状态从[" + s1 + "]改为[" + s2 + "]";
                        }
                        if (!data["jt_newid"].ToString().Equals(dt.Rows[0]["jt_newid"].ToString()))
                        {
                            if (string.IsNullOrEmpty(memo))
                                memo = "岗位：" + dt.Rows[0]["jt_name"].ToString() + "，将对应长三角编号从[" + dt.Rows[0]["jt_newid"].ToString() + "]改为[" + data["jt_newid"] + "]";
                            else
                                memo += "；将对应长三角编号从[" + dt.Rows[0]["jt_newid"].ToString() + "]改为[" + data["jt_newid"] + "]";
                        }
                        if (string.IsNullOrEmpty(memo))
                            memo = "岗位：" + dt.Rows[0]["jt_name"].ToString() + "，未修改任何字段";
                        MyCommand.CommandText = " update jobtype set jt_name=@jt_name,jt_id=@jt_id,jt_pid=@jt_pid,jt_state=@jt_state,jt_newid=@jt_newid where jt_no=@jt_no ";
                        res = MyCommand.ExecuteNonQuery();
                        if (res > 0)
                            WriteLog(data["user"].ToString(), 2, data["ip"].ToString(), "用户【" + data["name"].ToString() + "】，在岗位类别设置功能中进行了数据修改操作，修改记录为【" + memo + "】。", MyCommand);
                    }
                    else
                        res = 0;
                }
                else
                    res = 2;
            }
            MyTrans.Commit();
        }
        catch
        {
            MyTrans.Rollback("Tran");
            res = -1;
        }
        Close();
        return res;
    }

    public int DeleteJobType(string uid, string name, string ip, string jt_no)
    {
        int res = 0;
        Open();
        SqlCommand MyCommand = MyConnection.CreateCommand();
        SqlTransaction MyTrans = MyConnection.BeginTransaction("Tran");
        MyCommand.Connection = MyConnection;
        MyCommand.Transaction = MyTrans;
        try
        {
            string[] id = jt_no.Split(',');
            for (int i = 0; i < id.Length; i++)
            {
                MyCommand.CommandText = " select * from jobtype where jt_no=@jt_no ";
                MyCommand.Parameters.Add("@jt_no", SqlDbType.BigInt).Value = id[i];
                DataTable dt = new DataTable();
                SqlDataAdapter da = new SqlDataAdapter(MyCommand);
                da.Fill(dt);
                if (dt != null && dt.Rows.Count > 0)
                {
                    string memo = "岗位：" + dt.Rows[0]["jt_name"].ToString();
                    MyCommand.CommandText = "delete from jobtype where jt_no=@jt_no ";
                    res = MyCommand.ExecuteNonQuery();
                    if (res > 0)
                        WriteLog(uid, 3, ip, "用户【" + name + "】，在岗位类别设置功能中进行了数据删除操作，删除记录为【" + memo + "】。", MyCommand);
                }
                MyCommand.Parameters.Clear();
            }
            MyTrans.Commit();
            res = 1;
        }
        catch (Exception ex)
        {
            MyTrans.Rollback("Tran");
            res = -1;
        }
        Close();
        return res;
    }

    public int LockJobType(string uid, string name, string ip, string jt_no, string jt_state)
    {
        int res = 0;
        Open();
        SqlCommand MyCommand = MyConnection.CreateCommand();
        SqlTransaction MyTrans = MyConnection.BeginTransaction("Tran");
        MyCommand.Connection = MyConnection;
        MyCommand.Transaction = MyTrans;
        try
        {
            string[] id = jt_no.Split(',');
            for (int i = 0; i < id.Length; i++)
            {
                MyCommand.CommandText = " select * from jobtype where jt_no=@jt_no ";
                MyCommand.Parameters.Add("@jt_no", SqlDbType.BigInt).Value = id[i];
                DataTable dt = new DataTable();
                SqlDataAdapter da = new SqlDataAdapter(MyCommand);
                da.Fill(dt);
                if (dt != null && dt.Rows.Count > 0)
                {
                    string memo = "";
                    if (!jt_state.Equals(dt.Rows[0]["jt_state"].ToString()))
                    {
                        string s1 = "启用";
                        if (ConfigurationManager.AppSettings["StateDisable"].Equals(dt.Rows[0]["jt_state"].ToString()))
                            s1 = "禁用";
                        string s2 = "启用";
                        if (ConfigurationManager.AppSettings["StateDisable"].Equals(jt_state))
                            s2 = "禁用";
                        memo = "岗位：" + dt.Rows[0]["jt_name"].ToString() + "，将状态从[" + s1 + "]改为[" + s2 + "]";
                    }
                    if (string.IsNullOrEmpty(memo))
                        memo = "岗位：" + dt.Rows[0]["jt_name"].ToString() + "，未修改任何字段";
                    MyCommand.CommandText = "update jobtype set jt_state=@jt_state where jt_no=@jt_no ";
                    MyCommand.Parameters.Add("@jt_state", SqlDbType.Int).Value = jt_state;
                    res = MyCommand.ExecuteNonQuery();
                    if (res > 0)
                        WriteLog(uid, 2, ip, "用户【" + name + "】，在岗位类别设置功能中进行了数据修改操作，修改记录为【" + memo + "】。", MyCommand);
                }
                MyCommand.Parameters.Clear();
            }
            MyTrans.Commit();
            res = 1;
        }
        catch (Exception ex)
        {
            MyTrans.Rollback("Tran");
            res = -1;
        }
        Close();
        return res;
    }

    public Hashtable GetMajorType(string ma_no)
    {
        Open();
        SqlCommand MyCommand = new SqlCommand();
        MyCommand.Connection = MyConnection;

        MyCommand.CommandText = "select * from major where ma_no=@ma_no";
        MyCommand.Parameters.Add("@ma_no", SqlDbType.BigInt).Value = ma_no;
        DataTable data = new DataTable();
        SqlDataAdapter adapter = new SqlDataAdapter(MyCommand);
        adapter.Fill(data);
        Close();
        ArrayList da = DataTable2ArrayList(data);
        return da.Count > 0 ? (Hashtable)da[0] : null;
    }

    public DataTable GetMajorTypeByStateP(int ma_state)
    {
        Open();
        SqlCommand MyCommand = new SqlCommand();
        MyCommand.Connection = MyConnection;

        MyCommand.CommandText = "select * from major where ma_pid='0' and ma_state=@ma_state ";
        MyCommand.Parameters.Add("@ma_state", SqlDbType.Int).Value = ma_state;
        DataTable data = new DataTable();
        SqlDataAdapter adapter = new SqlDataAdapter(MyCommand);
        adapter.Fill(data);
        Close();
        return (data);
    }

    public DataTable GetMajorTypeByP(string ma_pid, int ma_state)
    {
        Open();
        SqlCommand MyCommand = new SqlCommand();
        MyCommand.Connection = MyConnection;

        MyCommand.CommandText = "select * from major where ma_pid<>'0' and ma_pid=@ma_pid and ma_state=@ma_state ";
        MyCommand.Parameters.Add("@ma_pid", SqlDbType.NVarChar).Value = ma_pid;
        MyCommand.Parameters.Add("@ma_state", SqlDbType.Int).Value = ma_state;
        DataTable data = new DataTable();
        SqlDataAdapter adapter = new SqlDataAdapter(MyCommand);
        adapter.Fill(data);
        Close();
        return (data);
    }

    public int SaveMajorType(Hashtable data)
    {
        int res;
        Open();
        SqlCommand MyCommand = MyConnection.CreateCommand();
        SqlTransaction MyTrans;
        MyTrans = MyConnection.BeginTransaction("Tran");
        MyCommand.Connection = MyConnection;
        MyCommand.Transaction = MyTrans;
        try
        {
            MyCommand.Parameters.Add("@ma_name", SqlDbType.NVarChar).Value = data["ma_name"];
            MyCommand.Parameters.Add("@ma_id", SqlDbType.NVarChar).Value = data["ma_id"];
            MyCommand.Parameters.Add("@ma_pid", SqlDbType.NVarChar).Value = data["ma_pid"];
            MyCommand.Parameters.Add("@ma_state", SqlDbType.Int).Value = data["ma_state"];
            MyCommand.Parameters.Add("@ma_newid", SqlDbType.NVarChar).Value = data["ma_newid"];
            if (string.IsNullOrEmpty(data["ma_no"].ToString()))
            {
                MyCommand.CommandText = " select count(1) from major where ma_name=@ma_name or ma_id=@ma_id ";
                int count = Convert.ToInt32(MyCommand.ExecuteScalar());
                if (count == 0)
                {
                    MyCommand.CommandText = " select ma_name from major where ma_id=@ma_pid ";
                    object obj = MyCommand.ExecuteScalar();
                    string pid = "无";
                    if (obj != null && !string.IsNullOrEmpty(obj.ToString()))
                        pid = obj.ToString();
                    MyCommand.CommandText = " insert into major (ma_name,ma_id,ma_pid,ma_state,ma_newid) values (@ma_name,@ma_id,@ma_pid,@ma_state,@ma_newid) ";
                    res = MyCommand.ExecuteNonQuery();
                    if (res > 0)
                        WriteLog(data["user"].ToString(), 1, data["ip"].ToString(), "用户【" + data["name"].ToString() + "】，在专业类别设置功能中进行了数据新增操作，新增记录为【专业名称：" + data["ma_name"] + "，父类：" + pid + "，专业编号：" + data["ma_id"] + "，对应长三角编号：" + data["ma_newid"] + "，状态：" + (ConfigurationManager.AppSettings["StateEnable"].Equals(data["ma_state"]) ? "启用" : "禁用") + "】。", MyCommand);
                    else
                        res = -1;
                }
                else
                    res = 2;
            }
            else
            {
                MyCommand.CommandText = " select count(1) from major where ma_no<>@ma_no and (ma_name=@ma_name or ma_id=@ma_id) ";
                MyCommand.Parameters.Add("@ma_no", SqlDbType.BigInt).Value = data["ma_no"];
                int count = Convert.ToInt32(MyCommand.ExecuteScalar());
                if (count == 0)
                {
                    MyCommand.CommandText = " select t1.*,case when t2.ma_name IS NULL then '无' end as pname from major t1 left join major t2 on t1.ma_pid = t2.ma_id where t1.ma_no=@ma_no ";
                    DataTable dt = new DataTable();
                    SqlDataAdapter da = new SqlDataAdapter(MyCommand);
                    da.Fill(dt);
                    if (dt != null && dt.Rows.Count > 0)
                    {
                        string memo = "";
                        if (!data["ma_name"].ToString().Equals(dt.Rows[0]["ma_name"].ToString()))
                            memo = "专业：" + dt.Rows[0]["ma_name"].ToString() + "，将专业名称从[" + dt.Rows[0]["ma_name"].ToString() + "]改为[" + data["ma_name"] + "]";
                        if (!data["ma_pid"].ToString().Equals(dt.Rows[0]["ma_pid"].ToString()))
                        {
                            MyCommand.CommandText = " select ma_name from major where ma_id=@ma_pid ";
                            object obj = MyCommand.ExecuteScalar();
                            string pid = "无";
                            if (obj != null && !string.IsNullOrEmpty(obj.ToString()))
                                pid = obj.ToString();
                            if (string.IsNullOrEmpty(memo))
                                memo = "专业：" + dt.Rows[0]["ma_name"].ToString() + "，将父类从[" + dt.Rows[0]["pname"].ToString() + "]改为[" + pid + "]";
                            else
                                memo += "；将父类从[" + dt.Rows[0]["pname"].ToString() + "]改为[" + pid + "]";
                        }
                        if (!data["ma_id"].ToString().Equals(dt.Rows[0]["ma_id"].ToString()))
                        {
                            if (string.IsNullOrEmpty(memo))
                                memo = "岗位：" + dt.Rows[0]["ma_name"].ToString() + "，将岗位编号从[" + dt.Rows[0]["ma_id"].ToString() + "]改为[" + data["ma_id"] + "]";
                            else
                                memo += "；将岗位编号从[" + dt.Rows[0]["ma_id"].ToString() + "]改为[" + data["ma_id"] + "]";
                        }
                        if (!data["ma_state"].ToString().Equals(dt.Rows[0]["ma_state"].ToString()))
                        {
                            string s1 = "启用";
                            if (ConfigurationManager.AppSettings["StateDisable"].Equals(dt.Rows[0]["ma_state"].ToString()))
                                s1 = "禁用";
                            string s2 = "启用";
                            if (ConfigurationManager.AppSettings["StateDisable"].Equals(data["ma_state"].ToString()))
                                s2 = "禁用";
                            if (string.IsNullOrEmpty(memo))
                                memo = "专业：" + dt.Rows[0]["ma_name"].ToString() + "，将状态从[" + s1 + "]改为[" + s2 + "]";
                            else
                                memo += "；将状态从[" + s1 + "]改为[" + s2 + "]";
                        }
                        if (!data["ma_newid"].ToString().Equals(dt.Rows[0]["ma_newid"].ToString()))
                        {
                            if (string.IsNullOrEmpty(memo))
                                memo = "专业：" + dt.Rows[0]["ma_name"].ToString() + "，将对应长三角编号从[" + dt.Rows[0]["ma_newid"].ToString() + "]改为[" + data["ma_newid"] + "]";
                            else
                                memo += "；将对应长三角编号从[" + dt.Rows[0]["ma_newid"].ToString() + "]改为[" + data["ma_newid"] + "]";
                        }
                        if (string.IsNullOrEmpty(memo))
                            memo = "专业：" + dt.Rows[0]["ma_name"].ToString() + "，未修改任何字段";
                        MyCommand.CommandText = " update major set ma_name=@ma_name,ma_id=@ma_id,ma_pid=@ma_pid,ma_state=@ma_state,ma_newid=@ma_newid where ma_no=@ma_no ";
                        res = MyCommand.ExecuteNonQuery();
                        if (res > 0)
                            WriteLog(data["user"].ToString(), 2, data["ip"].ToString(), "用户【" + data["name"].ToString() + "】，在专业类别设置功能中进行了数据修改操作，修改记录为【" + memo + "】。", MyCommand);
                    }
                    else
                        res = 0;
                }
                else
                    res = 2;
            }
            MyTrans.Commit();
        }
        catch
        {
            MyTrans.Rollback("Tran");
            res = -1;
        }
        Close();
        return res;
    }

    public int DeleteMajorType(string uid, string name, string ip, string ma_no)
    {
        int res = 0;
        Open();
        SqlCommand MyCommand = MyConnection.CreateCommand();
        SqlTransaction MyTrans = MyConnection.BeginTransaction("Tran");
        MyCommand.Connection = MyConnection;
        MyCommand.Transaction = MyTrans;
        try
        {
            string[] id = ma_no.Split(',');
            for (int i = 0; i < id.Length; i++)
            {
                MyCommand.CommandText = " select * from major where ma_no=@ma_no ";
                MyCommand.Parameters.Add("@ma_no", SqlDbType.BigInt).Value = id[i];
                DataTable dt = new DataTable();
                SqlDataAdapter da = new SqlDataAdapter(MyCommand);
                da.Fill(dt);
                if (dt != null && dt.Rows.Count > 0)
                {
                    string memo = "专业：" + dt.Rows[0]["ma_name"].ToString();
                    MyCommand.CommandText = "delete from major where ma_no=@ma_no ";
                    res = MyCommand.ExecuteNonQuery();
                    if (res > 0)
                        WriteLog(uid, 3, ip, "用户【" + name + "】，在专业类别设置功能中进行了数据删除操作，删除记录为【" + memo + "】。", MyCommand);
                }
                MyCommand.Parameters.Clear();
            }
            MyTrans.Commit();
            res = 1;
        }
        catch (Exception ex)
        {
            MyTrans.Rollback("Tran");
            res = -1;
        }
        Close();
        return res;
    }

    public int LockMajorType(string uid, string name, string ip, string ma_no, string ma_state)
    {
        int res = 0;
        Open();
        SqlCommand MyCommand = MyConnection.CreateCommand();
        SqlTransaction MyTrans = MyConnection.BeginTransaction("Tran");
        MyCommand.Connection = MyConnection;
        MyCommand.Transaction = MyTrans;
        try
        {
            string[] id = ma_no.Split(',');
            for (int i = 0; i < id.Length; i++)
            {
                MyCommand.CommandText = " select * from major where ma_no=@ma_no ";
                MyCommand.Parameters.Add("@ma_no", SqlDbType.BigInt).Value = id[i];
                DataTable dt = new DataTable();
                SqlDataAdapter da = new SqlDataAdapter(MyCommand);
                da.Fill(dt);
                if (dt != null && dt.Rows.Count > 0)
                {
                    string memo = "";
                    if (!ma_state.Equals(dt.Rows[0]["ma_state"].ToString()))
                    {
                        string s1 = "启用";
                        if (ConfigurationManager.AppSettings["StateDisable"].Equals(dt.Rows[0]["ma_state"].ToString()))
                            s1 = "禁用";
                        string s2 = "启用";
                        if (ConfigurationManager.AppSettings["StateDisable"].Equals(ma_state))
                            s2 = "禁用";
                        memo = "专业：" + dt.Rows[0]["ma_name"].ToString() + "，将状态从[" + s1 + "]改为[" + s2 + "]";
                    }
                    if (string.IsNullOrEmpty(memo))
                        memo = "专业：" + dt.Rows[0]["ma_name"].ToString() + "，未修改任何字段";
                    MyCommand.CommandText = "update major set ma_state=@ma_state where ma_no=@ma_no ";
                    MyCommand.Parameters.Add("@ma_state", SqlDbType.Int).Value = ma_state;
                    res = MyCommand.ExecuteNonQuery();
                    if (res > 0)
                        WriteLog(uid, 2, ip, "用户【" + name + "】，在专业类别设置功能中进行了数据修改操作，修改记录为【" + memo + "】。", MyCommand);
                }
                MyCommand.Parameters.Clear();
            }
            MyTrans.Commit();
            res = 1;
        }
        catch (Exception ex)
        {
            MyTrans.Rollback("Tran");
            res = -1;
        }
        Close();
        return res;
    }

    public Hashtable GetDictionary(string di_no)
    {
        Open();
        SqlCommand MyCommand = new SqlCommand();
        MyCommand.Connection = MyConnection;

        MyCommand.CommandText = "select * from dictionary where di_no=@di_no";
        MyCommand.Parameters.Add("@di_no", SqlDbType.BigInt).Value = di_no;
        DataTable data = new DataTable();
        SqlDataAdapter adapter = new SqlDataAdapter(MyCommand);
        adapter.Fill(data);
        Close();
        ArrayList da = DataTable2ArrayList(data);
        return da.Count > 0 ? (Hashtable)da[0] : null;
    }

    public int SaveDictionary(Hashtable data)
    {
        int res;
        Open();
        SqlCommand MyCommand = MyConnection.CreateCommand();
        SqlTransaction MyTrans;
        MyTrans = MyConnection.BeginTransaction("Tran");
        MyCommand.Connection = MyConnection;
        MyCommand.Transaction = MyTrans;
        try
        {
            MyCommand.Parameters.Add("@di_name", SqlDbType.NVarChar).Value = data["di_name"];
            MyCommand.Parameters.Add("@di_code", SqlDbType.NVarChar).Value = data["di_code"];
            MyCommand.Parameters.Add("@di_type", SqlDbType.Int).Value = data["di_type"];
            MyCommand.Parameters.Add("@di_state", SqlDbType.Int).Value = data["di_state"];
            MyCommand.Parameters.Add("@user", SqlDbType.NVarChar).Value = data["user"];
            MyCommand.Parameters.Add("@ip", SqlDbType.NVarChar).Value = data["ip"];
            if (string.IsNullOrEmpty(data["di_no"].ToString()))
            {
                MyCommand.CommandText = " select count(1) from dictionary where di_type=@di_type and (di_name=@di_name or di_code=@di_code) ";
                int count = Convert.ToInt32(MyCommand.ExecuteScalar());
                if (count == 0)
                {
                    string type = "";
                    if ("1".Equals(data["di_type"]))
                        type = "单位行业";
                    else if ("2".Equals(data["di_type"]))
                        type = "单位性质";
                    else if ("3".Equals(data["di_type"]))
                        type = "地区";
                    else if ("4".Equals(data["di_type"]))
                        type = "学历";
                    else if ("5".Equals(data["di_type"]))
                        type = "性别";
                    else if ("6".Equals(data["di_type"]))
                        type = "工作性质";
                    MyCommand.CommandText = " insert into dictionary (di_name,di_type,di_code,di_state,di_inserttime,di_insertuser,di_insertip) values (@di_name,@di_type,@di_code,@di_state,getdate(),@user,@ip) ";
                    res = MyCommand.ExecuteNonQuery();
                    if (res > 0)
                        WriteLog(data["user"].ToString(), 1, data["ip"].ToString(), "用户【" + data["name"].ToString() + "】，在系统字典管理功能中进行了数据新增操作，新增记录为【名称：" + data["di_name"] + "，类型：" + type + "，编号：" + data["di_code"] + "，状态：" + (ConfigurationManager.AppSettings["StateEnable"].Equals(data["di_state"]) ? "启用" : "禁用") + "】。", MyCommand);
                    else
                        res = -1;
                }
                else
                    res = 2;
            }
            else
            {
                MyCommand.CommandText = " select count(1) from dictionary where di_no<>@di_no and di_type=@di_type and (di_name=@di_name or di_code=@di_code)";
                MyCommand.Parameters.Add("@di_no", SqlDbType.BigInt).Value = data["di_no"];
                int count = Convert.ToInt32(MyCommand.ExecuteScalar());
                if (count == 0)
                {
                    MyCommand.CommandText = " select * from dictionary where di_no=@di_no ";
                    DataTable dt = new DataTable();
                    SqlDataAdapter da = new SqlDataAdapter(MyCommand);
                    da.Fill(dt);
                    if (dt != null && dt.Rows.Count > 0)
                    {
                        string memo = "";
                        if (!data["di_name"].ToString().Equals(dt.Rows[0]["di_name"].ToString()))
                            memo = "系统字典：" + dt.Rows[0]["di_name"].ToString() + "，将名称从[" + dt.Rows[0]["di_name"].ToString() + "]改为[" + data["di_name"] + "]";
                        if (!data["di_type"].ToString().Equals(dt.Rows[0]["di_type"].ToString()))
                        {
                            string type1 = "";
                            if ("1".Equals(dt.Rows[0]["di_type"].ToString()))
                                type1 = "单位行业";
                            else if ("2".Equals(dt.Rows[0]["di_type"].ToString()))
                                type1 = "单位性质";
                            else if ("3".Equals(dt.Rows[0]["di_type"].ToString()))
                                type1 = "地区";
                            else if ("4".Equals(dt.Rows[0]["di_type"].ToString()))
                                type1 = "学历";
                            else if ("5".Equals(dt.Rows[0]["di_type"].ToString()))
                                type1 = "性别";
                            else if ("6".Equals(dt.Rows[0]["di_type"].ToString()))
                                type1 = "工作性质";
                            string type2 = "";
                            if ("1".Equals(data["di_type"]))
                                type2 = "单位行业";
                            else if ("2".Equals(data["di_type"]))
                                type2 = "单位性质";
                            else if ("3".Equals(data["di_type"]))
                                type2 = "地区";
                            else if ("4".Equals(data["di_type"]))
                                type2 = "学历";
                            else if ("5".Equals(data["di_type"]))
                                type2 = "性别";
                            else if ("6".Equals(data["di_type"]))
                                type2 = "工作性质";
                            if (string.IsNullOrEmpty(memo))
                                memo = "系统字典：" + dt.Rows[0]["di_name"].ToString() + "，将类型从[" + type1 + "]改为[" + type2 + "]";
                            else
                                memo += "；将类型从[" + type1 + "]改为[" + type2 + "]";
                        }
                        if (!data["di_code"].ToString().Equals(dt.Rows[0]["di_code"].ToString()))
                        {
                            if (string.IsNullOrEmpty(memo))
                                memo = "系统字典：" + dt.Rows[0]["di_name"].ToString() + "，将编号从[" + dt.Rows[0]["di_code"].ToString() + "]改为[" + data["di_code"] + "]";
                            else
                                memo += "；将编号从[" + dt.Rows[0]["di_code"].ToString() + "]改为[" + data["di_code"] + "]";
                        }
                        if (!data["di_state"].ToString().Equals(dt.Rows[0]["di_state"].ToString()))
                        {
                            string s1 = "启用";
                            if (ConfigurationManager.AppSettings["StateDisable"].Equals(dt.Rows[0]["di_state"].ToString()))
                                s1 = "禁用";
                            string s2 = "启用";
                            if (ConfigurationManager.AppSettings["StateDisable"].Equals(data["di_state"].ToString()))
                                s2 = "禁用";
                            if (string.IsNullOrEmpty(memo))
                                memo = "系统字典：" + dt.Rows[0]["di_name"].ToString() + "，将状态从[" + s1 + "]改为[" + s2 + "]";
                            else
                                memo += "；将状态从[" + s1 + "]改为[" + s2 + "]";
                        }
                        if (string.IsNullOrEmpty(memo))
                            memo = "系统字典：" + dt.Rows[0]["ma_name"].ToString() + "，未修改任何字段";
                        MyCommand.CommandText = " update dictionary set di_name=@di_name,di_type=@di_type,di_code=@di_code,di_state=@di_state,di_modifytime=getdate(),di_modifyuser=@user,di_modifyip=@ip where di_no=@di_no ";
                        res = MyCommand.ExecuteNonQuery();
                        if (res > 0)
                            WriteLog(data["user"].ToString(), 2, data["ip"].ToString(), "用户【" + data["name"].ToString() + "】，在系统字典管理功能中进行了数据修改操作，修改记录为【" + memo + "】。", MyCommand);
                    }
                    else
                        res = 0;
                }
                else
                    res = 2;
            }
            MyTrans.Commit();
        }
        catch
        {
            MyTrans.Rollback("Tran");
            res = -1;
        }
        Close();
        return res;
    }

    public int DeleteDictionary(string uid, string name, string ip, string di_no)
    {
        int res = 0;
        Open();
        SqlCommand MyCommand = MyConnection.CreateCommand();
        SqlTransaction MyTrans = MyConnection.BeginTransaction("Tran");
        MyCommand.Connection = MyConnection;
        MyCommand.Transaction = MyTrans;
        try
        {
            string[] id = di_no.Split(',');
            for (int i = 0; i < id.Length; i++)
            {
                MyCommand.CommandText = " select * from dictionary where di_no=@di_no ";
                MyCommand.Parameters.Add("@di_no", SqlDbType.BigInt).Value = id[i];
                DataTable dt = new DataTable();
                SqlDataAdapter da = new SqlDataAdapter(MyCommand);
                da.Fill(dt);
                if (dt != null && dt.Rows.Count > 0)
                {
                    string memo = "系统字典：" + dt.Rows[0]["di_name"].ToString();
                    MyCommand.CommandText = "delete from dictionary where di_no=@di_no ";
                    res = MyCommand.ExecuteNonQuery();
                    if (res > 0)
                        WriteLog(uid, 3, ip, "用户【" + name + "】，在系统字典管理功能中进行了数据删除操作，删除记录为【" + memo + "】。", MyCommand);
                }
                MyCommand.Parameters.Clear();
            }
            MyTrans.Commit();
            res = 1;
        }
        catch (Exception ex)
        {
            MyTrans.Rollback("Tran");
            res = -1;
        }
        Close();
        return res;
    }

    public int LockDictionary(string uid, string name, string ip, string di_no, string di_state)
    {
        int res = 0;
        Open();
        SqlCommand MyCommand = MyConnection.CreateCommand();
        SqlTransaction MyTrans = MyConnection.BeginTransaction("Tran");
        MyCommand.Connection = MyConnection;
        MyCommand.Transaction = MyTrans;
        try
        {
            string[] id = di_no.Split(',');
            for (int i = 0; i < id.Length; i++)
            {
                MyCommand.CommandText = " select * from dictionary where di_no=@di_no ";
                MyCommand.Parameters.Add("@di_no", SqlDbType.BigInt).Value = id[i];
                DataTable dt = new DataTable();
                SqlDataAdapter da = new SqlDataAdapter(MyCommand);
                da.Fill(dt);
                if (dt != null && dt.Rows.Count > 0)
                {
                    string memo = "";
                    if (!di_state.Equals(dt.Rows[0]["di_state"].ToString()))
                    {
                        string s1 = "启用";
                        if (ConfigurationManager.AppSettings["StateDisable"].Equals(dt.Rows[0]["di_state"].ToString()))
                            s1 = "禁用";
                        string s2 = "启用";
                        if (ConfigurationManager.AppSettings["StateDisable"].Equals(di_state))
                            s2 = "禁用";
                        memo = "系统字典：" + dt.Rows[0]["di_name"].ToString() + "，将状态从[" + s1 + "]改为[" + s2 + "]";
                    }
                    if (string.IsNullOrEmpty(memo))
                        memo = "系统字典：" + dt.Rows[0]["di_name"].ToString() + "，未修改任何字段";
                    MyCommand.CommandText = "update dictionary set di_state=@di_state where di_no=@di_no ";
                    MyCommand.Parameters.Add("@di_state", SqlDbType.Int).Value = di_state;
                    res = MyCommand.ExecuteNonQuery();
                    if (res > 0)
                        WriteLog(uid, 2, ip, "用户【" + name + "】，在系统字典管理功能中进行了数据修改操作，修改记录为【" + memo + "】。", MyCommand);
                }
                MyCommand.Parameters.Clear();
            }
            MyTrans.Commit();
            res = 1;
        }
        catch (Exception ex)
        {
            MyTrans.Rollback("Tran");
            res = -1;
        }
        Close();
        return res;
    }

    public Hashtable GetWebset()
    {
        Open();
        SqlCommand MyCommand = new SqlCommand();
        MyCommand.Connection = MyConnection;

        MyCommand.CommandText = "select top 1 * from webset order by ws_no desc";
        DataTable data = new DataTable();
        SqlDataAdapter adapter = new SqlDataAdapter(MyCommand);
        adapter.Fill(data);
        Close();
        ArrayList da = DataTable2ArrayList(data);
        return da.Count > 0 ? (Hashtable)da[0] : null;
    }

    public int SaveWebset(Hashtable data)
    {
        int res;
        Open();
        SqlCommand MyCommand = MyConnection.CreateCommand();
        SqlTransaction MyTrans;
        MyTrans = MyConnection.BeginTransaction("Tran");
        MyCommand.Connection = MyConnection;
        MyCommand.Transaction = MyTrans;
        try
        {
            MyCommand.Parameters.Add("@ws_title", SqlDbType.NVarChar).Value = data["ws_title"];
            MyCommand.Parameters.Add("@ws_bewrite", SqlDbType.NVarChar).Value = data["ws_bewrite"];
            MyCommand.Parameters.Add("@ws_keyword", SqlDbType.NVarChar).Value = data["ws_keyword"];
            MyCommand.Parameters.Add("@ws_description", SqlDbType.NVarChar).Value = data["ws_description"];
            MyCommand.Parameters.Add("@ws_url", SqlDbType.NVarChar).Value = data["ws_url"];
            MyCommand.Parameters.Add("@ws_company", SqlDbType.NVarChar).Value = data["ws_company"];
            MyCommand.Parameters.Add("@ws_sponsor", SqlDbType.NVarChar).Value = data["ws_sponsor"];
            MyCommand.Parameters.Add("@ws_address", SqlDbType.NVarChar).Value = data["ws_address"];
            MyCommand.Parameters.Add("@ws_zip", SqlDbType.NVarChar).Value = data["ws_zip"];
            MyCommand.Parameters.Add("@ws_tel", SqlDbType.NVarChar).Value = data["ws_tel"];
            MyCommand.Parameters.Add("@ws_email", SqlDbType.NVarChar).Value = data["ws_email"];
            MyCommand.Parameters.Add("@ws_icp", SqlDbType.NVarChar).Value = data["ws_icp"];
            MyCommand.Parameters.Add("@ws_script", SqlDbType.NVarChar).Value = data["ws_script"];
            if (string.IsNullOrEmpty(data["ws_no"].ToString()))
            {
                MyCommand.CommandText = " insert into webset (ws_title,ws_bewrite,ws_keyword,ws_description,ws_url,ws_company,ws_sponsor,ws_address,ws_zip,ws_tel,ws_email,ws_icp,ws_script) values (@ws_title,@ws_bewrite,@ws_keyword,@ws_description,@ws_url,@ws_company,@ws_sponsor,@ws_address,@ws_zip,@ws_tel,@ws_email,@ws_icp,@ws_script) ";
                res = MyCommand.ExecuteNonQuery();
                if (res > 0)
                    WriteLog(data["user"].ToString(), 1, data["ip"].ToString(), "用户【" + data["name"].ToString() + "】，在网站基本设置功能中进行了数据新增操作，新增记录为【网站名称：" + data["ws_title"] + "，网站描述：" + data["ws_bewrite"] + "，keyword：" + data["ws_keyword"] + "，description：" + data["ws_description"] + "，域名：" + data["ws_url"] + "，网站单位：" + data["ws_company"] + "，网站主办方：" + data["ws_sponsor"] + "，联系地址：" + data["ws_address"] + "，邮编：" + data["ws_zip"] + "，联系电话：" + data["ws_tel"] + "，Email：" + data["ws_email"] + "，ICP：" + data["ws_icp"] + "，统计代码：" + data["ws_script"] + "】。", MyCommand);
                else
                    res = -1;
            }
            else
            {
                MyCommand.CommandText = " select * from webset where ws_no=@ws_no ";
                MyCommand.Parameters.Add("@ws_no", SqlDbType.Int).Value = data["ws_no"];
                DataTable dt = new DataTable();
                SqlDataAdapter da = new SqlDataAdapter(MyCommand);
                da.Fill(dt);
                if (dt != null && dt.Rows.Count > 0)
                {
                    string memo = "";
                    if (!data["ws_title"].ToString().Equals(dt.Rows[0]["ws_title"].ToString()))
                        memo = "网站基本信息：将网站名称从[" + dt.Rows[0]["ws_title"].ToString() + "]改为[" + data["ws_title"] + "]";
                    if (!data["ws_bewrite"].ToString().Equals(dt.Rows[0]["ws_bewrite"].ToString()))
                    {
                        if (string.IsNullOrEmpty(memo))
                            memo = "网站基本信息：将网站描述从[" + dt.Rows[0]["ws_bewrite"].ToString() + "]改为[" + data["ws_bewrite"] + "]";
                        else
                            memo += "；将网站描述从[" + dt.Rows[0]["ws_bewrite"].ToString() + "]改为[" + data["ws_bewrite"] + "]";
                    }
                    if (!data["ws_keyword"].ToString().Equals(dt.Rows[0]["ws_keyword"].ToString()))
                    {
                        if (string.IsNullOrEmpty(memo))
                            memo = "网站基本信息：将keyword从[" + dt.Rows[0]["ws_keyword"].ToString() + "]改为[" + data["ws_keyword"] + "]";
                        else
                            memo += "；将keyword从[" + dt.Rows[0]["ws_keyword"].ToString() + "]改为[" + data["ws_keyword"] + "]";
                    }
                    if (!data["ws_description"].ToString().Equals(dt.Rows[0]["ws_description"].ToString()))
                    {
                        if (string.IsNullOrEmpty(memo))
                            memo = "网站基本信息：将description从[" + dt.Rows[0]["ws_description"].ToString() + "]改为[" + data["ws_description"] + "]";
                        else
                            memo += "；将description从[" + dt.Rows[0]["ws_description"].ToString() + "]改为[" + data["ws_description"] + "]";
                    }
                    if (!data["ws_url"].ToString().Equals(dt.Rows[0]["ws_url"].ToString()))
                    {
                        if (string.IsNullOrEmpty(memo))
                            memo = "网站基本信息：将域名从[" + dt.Rows[0]["ws_url"].ToString() + "]改为[" + data["ws_url"] + "]";
                        else
                            memo += "；将域名从[" + dt.Rows[0]["ws_url"].ToString() + "]改为[" + data["ws_url"] + "]";
                    }
                    if (!data["ws_company"].ToString().Equals(dt.Rows[0]["ws_company"].ToString()))
                    {
                        if (string.IsNullOrEmpty(memo))
                            memo = "网站基本信息：将网站单位从[" + dt.Rows[0]["ws_company"].ToString() + "]改为[" + data["ws_company"] + "]";
                        else
                            memo += "；将网站单位从[" + dt.Rows[0]["ws_company"].ToString() + "]改为[" + data["ws_company"] + "]";
                    }
                    if (!data["ws_sponsor"].ToString().Equals(dt.Rows[0]["ws_sponsor"].ToString()))
                    {
                        if (string.IsNullOrEmpty(memo))
                            memo = "网站基本信息：将网站主办方从[" + dt.Rows[0]["ws_sponsor"].ToString() + "]改为[" + data["ws_sponsor"] + "]";
                        else
                            memo += "；将网站主办方从[" + dt.Rows[0]["ws_sponsor"].ToString() + "]改为[" + data["ws_sponsor"] + "]";
                    }
                    if (!data["ws_address"].ToString().Equals(dt.Rows[0]["ws_address"].ToString()))
                    {
                        if (string.IsNullOrEmpty(memo))
                            memo = "网站基本信息：将联系地址从[" + dt.Rows[0]["ws_address"].ToString() + "]改为[" + data["ws_address"] + "]";
                        else
                            memo += "；将联系地址从[" + dt.Rows[0]["ws_address"].ToString() + "]改为[" + data["ws_address"] + "]";
                    }
                    if (!data["ws_zip"].ToString().Equals(dt.Rows[0]["ws_zip"].ToString()))
                    {
                        if (string.IsNullOrEmpty(memo))
                            memo = "网站基本信息：将邮编从[" + dt.Rows[0]["ws_zip"].ToString() + "]改为[" + data["ws_zip"] + "]";
                        else
                            memo += "；将邮编从[" + dt.Rows[0]["ws_zip"].ToString() + "]改为[" + data["ws_zip"] + "]";
                    }
                    if (!data["ws_tel"].ToString().Equals(dt.Rows[0]["ws_tel"].ToString()))
                    {
                        if (string.IsNullOrEmpty(memo))
                            memo = "网站基本信息：将联系电话从[" + dt.Rows[0]["ws_tel"].ToString() + "]改为[" + data["ws_tel"] + "]";
                        else
                            memo += "；将联系电话从[" + dt.Rows[0]["ws_tel"].ToString() + "]改为[" + data["ws_tel"] + "]";
                    }
                    if (!data["ws_email"].ToString().Equals(dt.Rows[0]["ws_email"].ToString()))
                    {
                        if (string.IsNullOrEmpty(memo))
                            memo = "网站基本信息：将Email从[" + dt.Rows[0]["ws_email"].ToString() + "]改为[" + data["ws_email"] + "]";
                        else
                            memo += "；将Email从[" + dt.Rows[0]["ws_email"].ToString() + "]改为[" + data["ws_email"] + "]";
                    }
                    if (!data["ws_icp"].ToString().Equals(dt.Rows[0]["ws_icp"].ToString()))
                    {
                        if (string.IsNullOrEmpty(memo))
                            memo = "网站基本信息：将ICP从[" + dt.Rows[0]["ws_icp"].ToString() + "]改为[" + data["ws_icp"] + "]";
                        else
                            memo += "；将ICP从[" + dt.Rows[0]["ws_icp"].ToString() + "]改为[" + data["ws_icp"] + "]";
                    }
                    if (!data["ws_script"].ToString().Equals(dt.Rows[0]["ws_script"].ToString()))
                    {
                        if (string.IsNullOrEmpty(memo))
                            memo = "网站基本信息：将ICP从[" + dt.Rows[0]["ws_script"].ToString() + "]改为[" + data["ws_script"].ToString().Replace("&lt;", "<").Replace("&gt;", ">") + "]";
                        else
                            memo += "；将ICP从[" + dt.Rows[0]["ws_script"].ToString() + "]改为[" + data["ws_script"] + "]";
                    }
                    if (string.IsNullOrEmpty(memo))
                        memo = "网站基本信息：未修改任何字段";
                    MyCommand.CommandText = " update webset set ws_title=@ws_title,ws_bewrite=@ws_bewrite,ws_keyword=@ws_keyword,ws_description=@ws_description,ws_url=@ws_url,ws_company=@ws_company,ws_sponsor=@ws_sponsor,ws_address=@ws_address,ws_zip=@ws_zip,ws_tel=@ws_tel,ws_email=@ws_email,ws_icp=@ws_icp,ws_script=@ws_script where ws_no=@ws_no ";
                    res = MyCommand.ExecuteNonQuery();
                    if (res > 0)
                        WriteLog(data["user"].ToString(), 2, data["ip"].ToString(), "用户【" + data["name"].ToString() + "】，在网站基本设置功能中进行了数据修改操作，修改记录为【" + memo + "】。", MyCommand);
                }
                else
                    res = 0;
            }
            MyTrans.Commit();
        }
        catch
        {
            MyTrans.Rollback("Tran");
            res = -1;
        }
        Close();
        return res;
    }

    public DataTable GetDictionaryByType(int di_type, int di_state, string nohas)
    {
        Open();
        SqlCommand MyCommand = new SqlCommand();
        MyCommand.Connection = MyConnection;

        MyCommand.CommandText = "select * from dictionary where di_type=@di_type and di_state=@di_state and di_code<>@di_code ";
        MyCommand.Parameters.Add("@di_type", SqlDbType.Int).Value = di_type;
        MyCommand.Parameters.Add("@di_state", SqlDbType.Int).Value = di_state;
        MyCommand.Parameters.Add("@di_code", SqlDbType.NVarChar).Value = nohas;
        DataTable data = new DataTable();
        SqlDataAdapter adapter = new SqlDataAdapter(MyCommand);
        adapter.Fill(data);
        Close();
        return (data);
    }

    public DataTable GetDictionaryByType(int di_type, int di_state)
    {
        Open();
        SqlCommand MyCommand = new SqlCommand();
        MyCommand.Connection = MyConnection;

        MyCommand.CommandText = "select * from dictionary where di_type=@di_type and di_state=@di_state ";
        MyCommand.Parameters.Add("@di_type", SqlDbType.Int).Value = di_type;
        MyCommand.Parameters.Add("@di_state", SqlDbType.Int).Value = di_state;
        DataTable data = new DataTable();
        SqlDataAdapter adapter = new SqlDataAdapter(MyCommand);
        adapter.Fill(data);
        Close();
        return (data);
    }


    public int SavePartyPay(Hashtable data)
    {
        int res;
        Open();
        SqlCommand MyCommand = MyConnection.CreateCommand();
        SqlTransaction MyTrans;
        MyTrans = MyConnection.BeginTransaction("Tran");
        MyCommand.Connection = MyConnection;
        MyCommand.Transaction = MyTrans;
        try
        {
            MyCommand.Parameters.Add("@pp_name", SqlDbType.NVarChar).Value = data["pp_name"];
            MyCommand.Parameters.Add("@pp_money", SqlDbType.Decimal).Value = data["pp_money"];
            MyCommand.Parameters.Add("@pp_memo", SqlDbType.NText).Value = data["pp_memo"];
            MyCommand.Parameters.Add("@user", SqlDbType.NVarChar).Value = data["user"];
            MyCommand.Parameters.Add("@ip", SqlDbType.NVarChar).Value = data["ip"];

            MyCommand.CommandText = " insert into partypayment (pp_name,pp_money,pp_memo,pp_inserttime,pp_insertuser,pp_insertip) values (@pp_name,@pp_money,@pp_memo,getdate(),@user,@ip) ";
            res = MyCommand.ExecuteNonQuery();
            if (res > 0)
                WriteLog(data["user"].ToString(), 1, data["ip"].ToString(), "用户【" + data["name"].ToString() + "】，在党费缴纳记录管理管理功能中进行了缴费新增操作，新增记录为【党员：" + data["pp_name"] + "，费用：" + data["pp_money"] + "，备注：" + data["pp_memo"] + "】。", MyCommand);
            else
                res = -1;
            MyTrans.Commit();
        }
        catch
        {
            MyTrans.Rollback("Tran");
            res = -1;
        }
        Close();
        return res;
    }

    public int DeletePartyPay(string uid, string name, string ip, string pp_no)
    {
        int res = 0;
        Open();
        SqlCommand MyCommand = MyConnection.CreateCommand();
        SqlTransaction MyTrans = MyConnection.BeginTransaction("Tran");
        MyCommand.Connection = MyConnection;
        MyCommand.Transaction = MyTrans;
        try
        {
            string[] id = pp_no.Split(',');
            for (int i = 0; i < id.Length; i++)
            {
                MyCommand.CommandText = " select * from partypayment where pp_no=@pp_no ";
                MyCommand.Parameters.Add("@pp_no", SqlDbType.BigInt).Value = id[i];
                DataTable dt = new DataTable();
                SqlDataAdapter da = new SqlDataAdapter(MyCommand);
                da.Fill(dt);
                if (dt != null && dt.Rows.Count > 0)
                {
                    string memo = "党员：" + dt.Rows[0]["pp_name"].ToString() + "，" + dt.Rows[0]["pp_inserttime"].ToString() + "添加的费用[" + dt.Rows[0]["pp_money"].ToString() + "]";
                    MyCommand.CommandText = "delete from partypayment where pp_no=@pp_no ";
                    res = MyCommand.ExecuteNonQuery();
                    if (res > 0)
                        WriteLog(uid, 3, ip, "用户【" + name + "】，在党费缴纳记录管理功能中进行了缴费记录删除操作，删除记录为【" + memo + "】。", MyCommand);
                }
                MyCommand.Parameters.Clear();
            }
            MyTrans.Commit();
            res = 1;
        }
        catch (Exception ex)
        {
            MyTrans.Rollback("Tran");
            res = -1;
        }
        Close();
        return res;
    }

    public Hashtable GetLink(string fl_no)
    {
        Open();
        SqlCommand MyCommand = new SqlCommand();
        MyCommand.Connection = MyConnection;

        MyCommand.CommandText = "select * from friendlink where fl_no=@fl_no";
        MyCommand.Parameters.Add("@fl_no", SqlDbType.BigInt).Value = fl_no;
        DataTable data = new DataTable();
        SqlDataAdapter adapter = new SqlDataAdapter(MyCommand);
        adapter.Fill(data);
        Close();
        ArrayList da = DataTable2ArrayList(data);
        return da.Count > 0 ? (Hashtable)da[0] : null;
    }

    public int SaveLink(Hashtable data)
    {
        int res;
        Open();
        SqlCommand MyCommand = MyConnection.CreateCommand();
        SqlTransaction MyTrans;
        MyTrans = MyConnection.BeginTransaction("Tran");
        MyCommand.Connection = MyConnection;
        MyCommand.Transaction = MyTrans;
        try
        {
            MyCommand.Parameters.Add("@fl_type", SqlDbType.Int).Value = data["fl_type"];
            if (data["fl_area"] == null)
                MyCommand.Parameters.Add("@fl_area", SqlDbType.Int).Value = DBNull.Value;
            else
                MyCommand.Parameters.Add("@fl_area", SqlDbType.Int).Value = data["fl_area"];
            MyCommand.Parameters.Add("@fl_title", SqlDbType.NVarChar).Value = data["fl_title"];
            MyCommand.Parameters.Add("@fl_url", SqlDbType.NVarChar).Value = data["fl_url"];
            MyCommand.Parameters.Add("@fl_hide", SqlDbType.Int).Value = data["fl_hide"];
            if (data["fl_pic"] == null)
                MyCommand.Parameters.Add("@fl_pic", SqlDbType.NVarChar).Value = DBNull.Value;
            else
                MyCommand.Parameters.Add("@fl_pic", SqlDbType.NVarChar).Value = data["fl_pic"];
            MyCommand.Parameters.Add("@fl_orderid", SqlDbType.BigInt).Value = data["fl_orderid"];

            if (string.IsNullOrEmpty(data["fl_no"].ToString()))
            {
                //MyCommand.CommandText = " select count(1) from friendlink where fl_type=@fl_type and fl_title=@fl_title ";
                //int count = Convert.ToInt32(MyCommand.ExecuteScalar());
                //if (count == 0)
                //{
                string type = "";
                if ("1".Equals(data["fl_type"]))
                    type = "主网站";
                else if ("2".Equals(data["fl_type"]))
                    type = "党员之家";
                else if ("3".Equals(data["fl_type"]))
                    type = "高层次人才";
                else if ("4".Equals(data["fl_type"]))
                    type = "HR协会";
                MyCommand.CommandText = " insert into friendlink (fl_type,fl_title,fl_url,fl_pic,fl_orderid,fl_hide,fl_hits,fl_inserttime,fl_area) values (@fl_type,@fl_title,@fl_url,@fl_pic,@fl_orderid,@fl_hide,0,getdate(),@fl_area) ";
                res = MyCommand.ExecuteNonQuery();
                if (res > 0)
                    WriteLog(data["user"].ToString(), 1, data["ip"].ToString(), "用户【" + data["name"].ToString() + "】，在友情链接管理功能中进行了数据新增操作，新增记录为【所属网站：" + type + "，名称：" + data["fl_title"] + "】。", MyCommand);
                else
                    res = -1;
                //}
                //else
                //    res = 2;
            }
            else
            {
                //MyCommand.CommandText = " select count(1) from friendlink where fl_no<>@fl_no and fl_type=@fl_type and fl_title=@fl_title ";
                MyCommand.Parameters.Add("@fl_no", SqlDbType.BigInt).Value = data["fl_no"];
                //int count = Convert.ToInt32(MyCommand.ExecuteScalar());
                //if (count == 0)
                //{
                MyCommand.CommandText = " select * from friendlink where fl_no=@fl_no ";
                DataTable dt = new DataTable();
                SqlDataAdapter da = new SqlDataAdapter(MyCommand);
                da.Fill(dt);
                if (dt != null && dt.Rows.Count > 0)
                {
                    string memo = "";
                    if (!data["fl_type"].ToString().Equals(dt.Rows[0]["fl_type"].ToString()))
                    {
                        string type1 = "";
                        if ("1".Equals(data["fl_type"]))
                            type1 = "主网站";
                        else if ("2".Equals(data["fl_type"]))
                            type1 = "党员之家";
                        else if ("3".Equals(data["fl_type"]))
                            type1 = "高层次人才";
                        else if ("4".Equals(data["fl_type"]))
                            type1 = "HR协会";
                        string type2 = "";
                        if ("1".Equals(data["fl_type"]))
                            type2 = "主网站";
                        else if ("2".Equals(data["fl_type"]))
                            type2 = "党员之家";
                        else if ("3".Equals(data["fl_type"]))
                            type2 = "高层次人才";
                        else if ("4".Equals(data["fl_type"]))
                            type2 = "HR协会";
                        memo = "友情链接：" + dt.Rows[0]["fl_title"].ToString() + "，将所属网站从[" + type1 + "]改为[" + type2 + "]";
                    }
                    if (data["fl_area"] != null)
                    {
                        if (!data["fl_area"].ToString().Equals(dt.Rows[0]["fl_area"].ToString()))
                        {
                            string type1 = "";
                            if ("1".Equals(data["fl_area"]))
                                type1 = "市内人才网站";
                            else if ("2".Equals(data["fl_area"]))
                                type1 = "省内人才网站";
                            else if ("3".Equals(data["fl_area"]))
                                type1 = "其他省市人才网站";
                            else if ("4".Equals(data["fl_area"]))
                                type1 = "湖州市本地网站";
                            else if ("5".Equals(data["fl_area"]))
                                type1 = "其他友情链接";
                            string type2 = "";
                            if ("1".Equals(data["fl_area"]))
                                type2 = "市内人才网站";
                            else if ("2".Equals(data["fl_area"]))
                                type2 = "省内人才网站";
                            else if ("3".Equals(data["fl_area"]))
                                type2 = "其他省市人才网站";
                            else if ("4".Equals(data["fl_area"]))
                                type2 = "湖州市本地网站";
                            else if ("5".Equals(data["fl_area"]))
                                type2 = "其他友情链接";
                            if (string.IsNullOrEmpty(memo))
                                memo = "友情链接：" + dt.Rows[0]["fl_title"].ToString() + "，将类型从[" + type1 + "]改为[" + type2 + "]";
                            else
                                memo += "；将类型从[" + type1 + "]改为[" + type2 + "]";
                        }
                    }
                    if (!data["fl_title"].ToString().Equals(dt.Rows[0]["fl_title"].ToString()))
                    {
                        if (string.IsNullOrEmpty(memo))
                            memo = "友情链接：" + dt.Rows[0]["fl_title"].ToString() + "，将名称从[" + dt.Rows[0]["fl_title"].ToString() + "]改为[" + data["fl_title"] + "]";
                        else
                            memo += "；将名称从[" + dt.Rows[0]["fl_title"].ToString() + "]改为[" + data["fl_title"] + "]";
                    }
                    if (!data["fl_url"].ToString().Equals(dt.Rows[0]["fl_url"].ToString()))
                    {
                        if (string.IsNullOrEmpty(memo))
                            memo = "友情链接：" + dt.Rows[0]["fl_title"].ToString() + "，将链接地址从[" + dt.Rows[0]["fl_url"].ToString() + "]改为[" + data["fl_url"] + "]";
                        else
                            memo += "；将链接地址从[" + dt.Rows[0]["fl_url"].ToString() + "]改为[" + data["fl_url"] + "]";
                    }
                    if (data["fl_pic"] != null)
                    {
                        if (!data["fl_pic"].ToString().Equals(dt.Rows[0]["fl_pic"].ToString()))
                        {
                            if (string.IsNullOrEmpty(memo))
                                memo = "友情链接：" + dt.Rows[0]["fl_title"].ToString() + "，将链接图片从[" + dt.Rows[0]["fl_pic"].ToString() + "]改为[" + data["fl_pic"] + "]";
                            else
                                memo += "；将链接图片从[" + dt.Rows[0]["fl_pic"].ToString() + "]改为[" + data["fl_pic"] + "]";
                        }
                    }
                    if (!data["fl_orderid"].ToString().Equals(dt.Rows[0]["fl_orderid"].ToString()))
                    {
                        if (string.IsNullOrEmpty(memo))
                            memo = "友情链接：" + dt.Rows[0]["fl_title"].ToString() + "，将排序从[" + dt.Rows[0]["fl_orderid"].ToString() + "]改为[" + data["fl_orderid"].ToString() + "]";
                        else
                            memo += "；将排序从[" + dt.Rows[0]["fl_orderid"].ToString() + "]改为[" + data["fl_orderid"].ToString() + "]";
                    }
                    if (!data["fl_hide"].ToString().Equals(dt.Rows[0]["fl_hide"].ToString()))
                    {
                        string s1 = "显示";
                        if (ConfigurationManager.AppSettings["Close"].Equals(dt.Rows[0]["fl_hide"].ToString()))
                            s1 = "隐藏";
                        string s2 = "显示";
                        if (ConfigurationManager.AppSettings["Close"].Equals(data["fl_hide"].ToString()))
                            s2 = "隐藏";
                        if (string.IsNullOrEmpty(memo))
                            memo = "友情链接：" + dt.Rows[0]["fl_title"].ToString() + "，将状态从[" + s1 + "]改为[" + s2 + "]";
                        else
                            memo += "；将状态从[" + s1 + "]改为[" + s2 + "]";
                    }
                    if (string.IsNullOrEmpty(memo))
                        memo = "友情链接：" + dt.Rows[0]["fl_title"].ToString() + "，未修改任何字段";
                    MyCommand.CommandText = " update friendlink set fl_type=@fl_type,fl_area=@fl_area,fl_title=@fl_title,fl_url=@fl_url,fl_pic=@fl_pic,fl_hide=@fl_hide,fl_orderid=@fl_orderid where fl_no=@fl_no ";
                    res = MyCommand.ExecuteNonQuery();
                    if (res > 0)
                        WriteLog(data["user"].ToString(), 2, data["ip"].ToString(), "用户【" + data["name"].ToString() + "】，在友情链接管理功能中进行了数据修改操作，修改记录为【" + memo + "】。", MyCommand);
                }
                else
                    res = 0;
                //}
                //else
                //    res = 2;
            }
            MyTrans.Commit();
        }
        catch
        {
            MyTrans.Rollback("Tran");
            res = -1;
        }
        Close();
        return res;
    }

    /// <summary>
    /// 删除友情链接
    /// </summary>
    /// <param name="uid"></param>
    /// <param name="name"></param>
    /// <param name="ip"></param>
    /// <param name="fl_no"></param>
    /// <returns></returns>
    public int DeleteLink(string uid, string name, string ip, string fl_no)
    {
        int res = 0;
        Open();
        SqlCommand MyCommand = MyConnection.CreateCommand();
        SqlTransaction MyTrans = MyConnection.BeginTransaction("Tran");
        MyCommand.Connection = MyConnection;
        MyCommand.Transaction = MyTrans;
        try
        {
            string[] id = fl_no.Split(',');
            for (int i = 0; i < id.Length; i++)
            {
                MyCommand.CommandText = " select * from friendlink where fl_no=@fl_no ";
                MyCommand.Parameters.Add("@fl_no", SqlDbType.BigInt).Value = id[i];
                DataTable dt = new DataTable();
                SqlDataAdapter da = new SqlDataAdapter(MyCommand);
                da.Fill(dt);
                if (dt != null && dt.Rows.Count > 0)
                {
                    string memo = "友情链接：" + dt.Rows[0]["fl_title"].ToString();
                    MyCommand.CommandText = "delete from friendlink where fl_no=@fl_no ";
                    res = MyCommand.ExecuteNonQuery();
                    if (res > 0)
                        WriteLog(uid, 3, ip, "用户【" + name + "】，在友情链接管理功能中进行了数据删除操作，删除记录为【" + memo + "】。", MyCommand);
                }
                MyCommand.Parameters.Clear();
            }
            MyTrans.Commit();
            res = 1;
        }
        catch (Exception ex)
        {
            MyTrans.Rollback("Tran");
            res = -1;
        }
        Close();
        return res;
    }

    public int LockLink(string uid, string name, string ip, string fl_no, string fl_hide)
    {
        int res = 0;
        Open();
        SqlCommand MyCommand = MyConnection.CreateCommand();
        SqlTransaction MyTrans = MyConnection.BeginTransaction("Tran");
        MyCommand.Connection = MyConnection;
        MyCommand.Transaction = MyTrans;
        try
        {
            string[] id = fl_no.Split(',');
            for (int i = 0; i < id.Length; i++)
            {
                MyCommand.CommandText = " select * from friendlink where fl_no=@fl_no ";
                MyCommand.Parameters.Add("@fl_no", SqlDbType.BigInt).Value = id[i];
                DataTable dt = new DataTable();
                SqlDataAdapter da = new SqlDataAdapter(MyCommand);
                da.Fill(dt);
                if (dt != null && dt.Rows.Count > 0)
                {
                    string memo = "";
                    if (!fl_hide.Equals(dt.Rows[0]["fl_hide"].ToString()))
                    {
                        string s1 = "隐藏";
                        if (ConfigurationManager.AppSettings["Open"].Equals(dt.Rows[0]["fl_hide"].ToString()))
                            s1 = "显示";
                        string s2 = "隐藏";
                        if (ConfigurationManager.AppSettings["Open"].Equals(fl_hide))
                            s2 = "显示";
                        memo = "友情链接：" + dt.Rows[0]["fl_title"].ToString() + "，将状态从[" + s1 + "]改为[" + s2 + "]";
                    }
                    if (string.IsNullOrEmpty(memo))
                        memo = "友情链接：" + dt.Rows[0]["fl_title"].ToString() + "，未修改任何字段";
                    MyCommand.CommandText = "update friendlink set fl_hide=@fl_hide where fl_no=@fl_no ";
                    MyCommand.Parameters.Add("@fl_hide", SqlDbType.Int).Value = fl_hide;
                    res = MyCommand.ExecuteNonQuery();
                    if (res > 0)
                        WriteLog(uid, 2, ip, "用户【" + name + "】，在友情链接管理功能中进行了数据修改操作，修改记录为【" + memo + "】。", MyCommand);
                }
                MyCommand.Parameters.Clear();
            }
            MyTrans.Commit();
            res = 1;
        }
        catch (Exception ex)
        {
            MyTrans.Rollback("Tran");
            res = -1;
        }
        Close();
        return res;
    }

    public int TopLink(string uid, string name, string ip, string fl_no, string fl_orderid)
    {
        int res = 0;
        Open();
        SqlCommand MyCommand = MyConnection.CreateCommand();
        SqlTransaction MyTrans = MyConnection.BeginTransaction("Tran");
        MyCommand.Connection = MyConnection;
        MyCommand.Transaction = MyTrans;
        try
        {
            MyCommand.CommandText = " select * from friendlink where fl_no=@fl_no ";
            MyCommand.Parameters.Add("@fl_no", SqlDbType.BigInt).Value = fl_no;
            DataTable dt = new DataTable();
            SqlDataAdapter da = new SqlDataAdapter(MyCommand);
            da.Fill(dt);
            if (dt != null && dt.Rows.Count > 0)
            {
                string memo = "";
                if (!fl_orderid.Equals(dt.Rows[0]["fl_orderid"].ToString()))
                {
                    memo = "友情链接：" + dt.Rows[0]["fl_title"].ToString() + "，将排序从[" + dt.Rows[0]["fl_orderid"].ToString() + "]改为[" + fl_orderid + "]";
                }
                if (string.IsNullOrEmpty(memo))
                    memo = "友情链接：" + dt.Rows[0]["fl_title"].ToString() + "，未修改任何字段";
                MyCommand.CommandText = "update friendlink set fl_orderid=@fl_orderid where fl_no=@fl_no ";
                MyCommand.Parameters.Add("@fl_orderid", SqlDbType.BigInt).Value = fl_orderid;
                res = MyCommand.ExecuteNonQuery();
                if (res > 0)
                    WriteLog(uid, 2, ip, "用户【" + name + "】，在友情链接管理功能中进行了数据修改操作，修改记录为【" + memo + "】。", MyCommand);
            }
            MyTrans.Commit();
            res = 1;
        }
        catch (Exception ex)
        {
            MyTrans.Rollback("Tran");
            res = -1;
        }
        Close();
        return res;
    }

    public Hashtable GetAd(string ad_no)
    {
        Open();
        SqlCommand MyCommand = new SqlCommand();
        MyCommand.Connection = MyConnection;

        MyCommand.CommandText = "select * from advertisement where ad_no=@ad_no";
        MyCommand.Parameters.Add("@ad_no", SqlDbType.BigInt).Value = ad_no;
        DataTable data = new DataTable();
        SqlDataAdapter adapter = new SqlDataAdapter(MyCommand);
        adapter.Fill(data);
        Close();
        ArrayList da = DataTable2ArrayList(data);
        return da.Count > 0 ? (Hashtable)da[0] : null;
    }

    public int SaveAd(Hashtable data)
    {
        int res;
        Open();
        SqlCommand MyCommand = MyConnection.CreateCommand();
        SqlTransaction MyTrans;
        MyTrans = MyConnection.BeginTransaction("Tran");
        MyCommand.Connection = MyConnection;
        MyCommand.Transaction = MyTrans;
        try
        {
            MyCommand.Parameters.Add("@ad_type", SqlDbType.Int).Value = data["ad_type"];
            MyCommand.Parameters.Add("@ad_title", SqlDbType.NVarChar).Value = data["ad_title"];
            MyCommand.Parameters.Add("@ad_url", SqlDbType.NVarChar).Value = data["ad_url"];
            MyCommand.Parameters.Add("@ad_img", SqlDbType.NVarChar).Value = data["ad_img"];
            MyCommand.Parameters.Add("@ad_effecttime", SqlDbType.Int).Value = data["ad_effecttime"];
            MyCommand.Parameters.Add("@ad_orderid", SqlDbType.BigInt).Value = data["ad_orderid"];
            MyCommand.Parameters.Add("@ad_hide", SqlDbType.Int).Value = data["ad_hide"];

            if (string.IsNullOrEmpty(data["ad_no"].ToString()))
            {
                //MyCommand.CommandText = " select count(1) from advertisement where ad_type=@ad_type and ad_title=@ad_title ";
                //int count = Convert.ToInt32(MyCommand.ExecuteScalar());
                //if (count == 0)
                //{
                string type = "";
                if ("1".Equals(data["ad_type"]))
                    type = "置顶广告";
                else if ("2".Equals(data["ad_type"]))
                    type = "首页上横幅（全）广告";
                else if ("3".Equals(data["ad_type"]))
                    type = "首页横幅（半）广告";
                else if ("4".Equals(data["ad_type"]))
                    type = "图标招聘广告";
                else if ("5".Equals(data["ad_type"]))
                    type = "首页挂边广告";
                else if ("6".Equals(data["ad_type"]))
                    type = "首页下横幅（全）广告";
                MyCommand.CommandText = " insert into advertisement (ad_type,ad_title,ad_url,ad_img,ad_effecttime,ad_orderid,ad_hide,ad_hits,ad_inserttime) values (@ad_type,@ad_title,@ad_url,@ad_img,@ad_effecttime,@ad_orderid,@ad_hide,0,getdate()) ";
                res = MyCommand.ExecuteNonQuery();
                if (res > 0)
                    WriteLog(data["user"].ToString(), 1, data["ip"].ToString(), "用户【" + data["name"].ToString() + "】，在广告管理功能中进行了数据新增操作，新增记录为【广告类型：" + type + "，名称：" + data["ad_title"] + "】。", MyCommand);
                else
                    res = -1;
                //}
                //else
                //    res = 2;
            }
            else
            {
                //MyCommand.CommandText = " select count(1) from advertisement where ad_no<>@ad_no and ad_type=@ad_type and ad_title=@ad_title ";
                MyCommand.Parameters.Add("@ad_no", SqlDbType.BigInt).Value = data["ad_no"];
                //int count = Convert.ToInt32(MyCommand.ExecuteScalar());
                //if (count == 0)
                //{
                MyCommand.CommandText = " select * from advertisement where ad_no=@ad_no ";
                DataTable dt = new DataTable();
                SqlDataAdapter da = new SqlDataAdapter(MyCommand);
                da.Fill(dt);
                if (dt != null && dt.Rows.Count > 0)
                {
                    string memo = "";
                    if (!data["ad_type"].ToString().Equals(dt.Rows[0]["ad_type"].ToString()))
                    {
                        string type1 = "";
                        if ("1".Equals(data["ad_type"]))
                            type1 = "置顶广告";
                        else if ("2".Equals(data["ad_type"]))
                            type1 = "首页上横幅（全）广告";
                        else if ("3".Equals(data["ad_type"]))
                            type1 = "首页横幅（半）广告";
                        else if ("4".Equals(data["ad_type"]))
                            type1 = "图标招聘广告";
                        else if ("5".Equals(data["ad_type"]))
                            type1 = "首页挂边广告";
                        else if ("6".Equals(data["ad_type"]))
                            type1 = "首页下横幅（全）广告";
                        string type2 = "";
                        if ("1".Equals(data["ad_type"]))
                            type2 = "置顶广告";
                        else if ("2".Equals(data["ad_type"]))
                            type2 = "首页上横幅（全）广告";
                        else if ("3".Equals(data["ad_type"]))
                            type2 = "首页横幅（半）广告";
                        else if ("4".Equals(data["ad_type"]))
                            type2 = "图标招聘广告";
                        else if ("5".Equals(data["ad_type"]))
                            type2 = "首页挂边广告";
                        else if ("6".Equals(data["ad_type"]))
                            type2 = "首页下横幅（全）广告";
                        memo = "广告：" + dt.Rows[0]["ad_title"].ToString() + "，将广告类型从[" + type1 + "]改为[" + type2 + "]";
                    }
                    if (!data["ad_title"].ToString().Equals(dt.Rows[0]["ad_title"].ToString()))
                    {
                        if (string.IsNullOrEmpty(memo))
                            memo = "广告：" + dt.Rows[0]["ad_title"].ToString() + "，将名称从[" + dt.Rows[0]["ad_title"].ToString() + "]改为[" + data["ad_title"] + "]";
                        else
                            memo += "；将名称从[" + dt.Rows[0]["ad_title"].ToString() + "]改为[" + data["ad_title"] + "]";
                    }
                    if (!data["ad_url"].ToString().Equals(dt.Rows[0]["ad_url"].ToString()))
                    {
                        if (string.IsNullOrEmpty(memo))
                            memo = "广告：" + dt.Rows[0]["ad_title"].ToString() + "，将链接地址从[" + dt.Rows[0]["ad_url"].ToString() + "]改为[" + data["ad_url"] + "]";
                        else
                            memo += "；将链接地址从[" + dt.Rows[0]["ad_url"].ToString() + "]改为[" + data["ad_url"] + "]";
                    }
                    if (!data["ad_img"].ToString().Equals(dt.Rows[0]["ad_img"].ToString()))
                    {
                        if (string.IsNullOrEmpty(memo))
                            memo = "广告：" + dt.Rows[0]["ad_title"].ToString() + "，将链接图片从[" + dt.Rows[0]["ad_img"].ToString() + "]改为[" + data["ad_img"] + "]";
                        else
                            memo += "；将链接图片从[" + dt.Rows[0]["ad_img"].ToString() + "]改为[" + data["ad_img"] + "]";
                    }
                    if (!data["ad_effecttime"].ToString().Equals(dt.Rows[0]["ad_effecttime"].ToString()))
                    {
                        if (string.IsNullOrEmpty(memo))
                            memo = "广告：" + dt.Rows[0]["ad_title"].ToString() + "，将有效期限从[" + dt.Rows[0]["ad_effecttime"].ToString() + "]改为[" + data["ad_effecttime"] + "]";
                        else
                            memo += "；将有效期限从[" + dt.Rows[0]["ad_effecttime"].ToString() + "]改为[" + data["ad_effecttime"] + "]";
                    }
                    if (!data["ad_orderid"].ToString().Equals(dt.Rows[0]["ad_orderid"].ToString()))
                    {
                        if (string.IsNullOrEmpty(memo))
                            memo = "广告：" + dt.Rows[0]["ad_title"].ToString() + "，将排序从[" + dt.Rows[0]["ad_orderid"].ToString() + "]改为[" + data["ad_orderid"].ToString() + "]";
                        else
                            memo += "；将置顶从[" + dt.Rows[0]["ad_orderid"].ToString() + "]改为[" + data["ad_orderid"].ToString() + "]";
                    }
                    if (!data["ad_hide"].ToString().Equals(dt.Rows[0]["ad_hide"].ToString()))
                    {
                        string s1 = "显示";
                        if (ConfigurationManager.AppSettings["Close"].Equals(dt.Rows[0]["ad_hide"].ToString()))
                            s1 = "隐藏";
                        string s2 = "显示";
                        if (ConfigurationManager.AppSettings["Close"].Equals(data["ad_hide"].ToString()))
                            s2 = "隐藏";
                        if (string.IsNullOrEmpty(memo))
                            memo = "广告：" + dt.Rows[0]["ad_title"].ToString() + "，将状态从[" + s1 + "]改为[" + s2 + "]";
                        else
                            memo += "；将状态从[" + s1 + "]改为[" + s2 + "]";
                    }
                    if (string.IsNullOrEmpty(memo))
                        memo = "广告：" + dt.Rows[0]["ad_title"].ToString() + "，未修改任何字段";
                    if ("0".Equals(data["ad_orderid"]))
                        MyCommand.CommandText = " update advertisement set ad_type=@ad_type,ad_title=@ad_title,ad_url=@ad_url,ad_img=@ad_img,ad_effecttime=@ad_effecttime,ad_orderid=@ad_orderid,ad_hide=@ad_hide where ad_no=@ad_no ";
                    else if ("1".Equals(data["ad_orderid"]) && !"0".Equals(dt.Rows[0]["ad_orderid"].ToString()))
                        MyCommand.CommandText = " update advertisement set ad_type=@ad_type,ad_title=@ad_title,ad_url=@ad_url,ad_img=@ad_img,ad_effecttime=@ad_effecttime,ad_orderid=0,ad_hide=@ad_hide where ad_no=@ad_no ";
                    else
                        MyCommand.CommandText = " update advertisement set ad_type=@ad_type,ad_title=@ad_title,ad_url=@ad_url,ad_img=@ad_img,ad_effecttime=@ad_effecttime,ad_orderid=(select isnull(MAX(ad_orderid),0) + 1 from advertisement),ad_hide=@ad_hide where ad_no=@ad_no ";
                    res = MyCommand.ExecuteNonQuery();
                    if (res > 0)
                        WriteLog(data["user"].ToString(), 2, data["ip"].ToString(), "用户【" + data["name"].ToString() + "】，在广告管理功能中进行了数据修改操作，修改记录为【" + memo + "】。", MyCommand);
                }
                else
                    res = 0;
                //}
                //else
                //    res = 2;
            }
            MyTrans.Commit();
        }
        catch
        {
            MyTrans.Rollback("Tran");
            res = -1;
        }
        Close();
        return res;
    }

    /// <summary>
    /// 删除广告
    /// </summary>
    /// <param name="uid"></param>
    /// <param name="name"></param>
    /// <param name="ip"></param>
    /// <param name="ad_no"></param>
    /// <returns></returns>
    public int DeleteAd(string uid, string name, string ip, string ad_no)
    {
        int res = 0;
        Open();
        SqlCommand MyCommand = MyConnection.CreateCommand();
        SqlTransaction MyTrans = MyConnection.BeginTransaction("Tran");
        MyCommand.Connection = MyConnection;
        MyCommand.Transaction = MyTrans;
        try
        {
            string[] id = ad_no.Split(',');
            for (int i = 0; i < id.Length; i++)
            {
                MyCommand.CommandText = " select * from advertisement where ad_no=@ad_no ";
                MyCommand.Parameters.Add("@ad_no", SqlDbType.BigInt).Value = id[i];
                DataTable dt = new DataTable();
                SqlDataAdapter da = new SqlDataAdapter(MyCommand);
                da.Fill(dt);
                if (dt != null && dt.Rows.Count > 0)
                {
                    string memo = "广告：" + dt.Rows[0]["ad_title"].ToString();
                    MyCommand.CommandText = "delete from advertisement where ad_no=@ad_no ";
                    res = MyCommand.ExecuteNonQuery();
                    if (res > 0)
                        WriteLog(uid, 3, ip, "用户【" + name + "】，在广告管理功能中进行了数据删除操作，删除记录为【" + memo + "】。", MyCommand);
                }
                MyCommand.Parameters.Clear();
            }
            MyTrans.Commit();
            res = 1;
        }
        catch (Exception ex)
        {
            MyTrans.Rollback("Tran");
            res = -1;
        }
        Close();
        return res;
    }

    public int LockAd(string uid, string name, string ip, string ad_no, string ad_hide)
    {
        int res = 0;
        Open();
        SqlCommand MyCommand = MyConnection.CreateCommand();
        SqlTransaction MyTrans = MyConnection.BeginTransaction("Tran");
        MyCommand.Connection = MyConnection;
        MyCommand.Transaction = MyTrans;
        try
        {
            string[] id = ad_no.Split(',');
            for (int i = 0; i < id.Length; i++)
            {
                MyCommand.CommandText = " select * from advertisement where ad_no=@ad_no ";
                MyCommand.Parameters.Add("@ad_no", SqlDbType.BigInt).Value = id[i];
                DataTable dt = new DataTable();
                SqlDataAdapter da = new SqlDataAdapter(MyCommand);
                da.Fill(dt);
                if (dt != null && dt.Rows.Count > 0)
                {
                    string memo = "";
                    if (!ad_hide.Equals(dt.Rows[0]["ad_hide"].ToString()))
                    {
                        string s1 = "隐藏";
                        if (ConfigurationManager.AppSettings["Open"].Equals(dt.Rows[0]["ad_hide"].ToString()))
                            s1 = "显示";
                        string s2 = "隐藏";
                        if (ConfigurationManager.AppSettings["Open"].Equals(ad_hide))
                            s2 = "显示";
                        memo = "广告：" + dt.Rows[0]["ad_title"].ToString() + "，将状态从[" + s1 + "]改为[" + s2 + "]";
                    }
                    if (string.IsNullOrEmpty(memo))
                        memo = "广告：" + dt.Rows[0]["ad_title"].ToString() + "，未修改任何字段";
                    MyCommand.CommandText = "update advertisement set ad_hide=@ad_hide where ad_no=@ad_no ";
                    MyCommand.Parameters.Add("@ad_hide", SqlDbType.Int).Value = ad_hide;
                    res = MyCommand.ExecuteNonQuery();
                    if (res > 0)
                        WriteLog(uid, 2, ip, "用户【" + name + "】，在广告管理功能中进行了数据修改操作，修改记录为【" + memo + "】。", MyCommand);
                }
                MyCommand.Parameters.Clear();
            }
            MyTrans.Commit();
            res = 1;
        }
        catch (Exception ex)
        {
            MyTrans.Rollback("Tran");
            res = -1;
        }
        Close();
        return res;
    }

    public int TopAd(string uid, string name, string ip, string ad_no, string ad_orderid)
    {
        int res = 0;
        Open();
        SqlCommand MyCommand = MyConnection.CreateCommand();
        SqlTransaction MyTrans = MyConnection.BeginTransaction("Tran");
        MyCommand.Connection = MyConnection;
        MyCommand.Transaction = MyTrans;
        try
        {
            MyCommand.CommandText = " select * from advertisement where ad_no=@ad_no ";
            MyCommand.Parameters.Add("@ad_no", SqlDbType.BigInt).Value = ad_no;
            DataTable dt = new DataTable();
            SqlDataAdapter da = new SqlDataAdapter(MyCommand);
            da.Fill(dt);
            if (dt != null && dt.Rows.Count > 0)
            {
                string memo = "";
                if (!ad_orderid.Equals(dt.Rows[0]["ad_orderid"].ToString()))
                {
                    memo = "广告：" + dt.Rows[0]["ad_title"].ToString() + "，将排序从[" + dt.Rows[0]["ad_orderid"].ToString() + "]改为[" + ad_orderid + "]";
                }
                if (string.IsNullOrEmpty(memo))
                    memo = "广告：" + dt.Rows[0]["ad_title"].ToString() + "，未修改任何字段";
                MyCommand.CommandText = "update advertisement set ad_orderid=@ad_orderid where ad_no=@ad_no ";
                MyCommand.Parameters.Add("@ad_orderid", SqlDbType.BigInt).Value = ad_orderid;
                res = MyCommand.ExecuteNonQuery();
                if (res > 0)
                    WriteLog(uid, 2, ip, "用户【" + name + "】，在广告管理功能中进行了数据修改操作，修改记录为【" + memo + "】。", MyCommand);
            }
            MyTrans.Commit();
            res = 1;
        }
        catch (Exception ex)
        {
            MyTrans.Rollback("Tran");
            res = -1;
        }
        Close();
        return res;
    }

    public int SelectAd(string uid, string name, string ip, string ad_no, string ad_select)
    {
        int res = 0;
        Open();
        SqlCommand MyCommand = MyConnection.CreateCommand();
        SqlTransaction MyTrans = MyConnection.BeginTransaction("Tran");
        MyCommand.Connection = MyConnection;
        MyCommand.Transaction = MyTrans;
        try
        {
            string[] id = ad_no.Split(',');
            for (int i = 0; i < id.Length; i++)
            {
                MyCommand.CommandText = " select * from advertisement where ad_no=@ad_no ";
                MyCommand.Parameters.Add("@ad_no", SqlDbType.BigInt).Value = id[i];
                DataTable dt = new DataTable();
                SqlDataAdapter da = new SqlDataAdapter(MyCommand);
                da.Fill(dt);
                if (dt != null && dt.Rows.Count > 0)
                {
                    string memo = "";
                    if (!ad_select.Equals(dt.Rows[0]["ad_select"].ToString()))
                    {
                        string s1 = "取消";
                        if (ConfigurationManager.AppSettings["Open"].Equals(dt.Rows[0]["ad_select"].ToString()))
                            s1 = "设置";
                        string s2 = "取消";
                        if (ConfigurationManager.AppSettings["Open"].Equals(ad_select))
                            s2 = "设置";
                        memo = "广告：" + dt.Rows[0]["ad_title"].ToString() + "，将状态从[" + s1 + "]改为[" + s2 + "]";
                    }
                    if (string.IsNullOrEmpty(memo))
                        memo = "广告：" + dt.Rows[0]["ad_title"].ToString() + "，未修改任何字段";
                    MyCommand.CommandText = "update advertisement set ad_select=@ad_select where ad_no=@ad_no ";
                    MyCommand.Parameters.Add("@ad_hide", SqlDbType.Int).Value = ad_select;
                    res = MyCommand.ExecuteNonQuery();
                    if (res > 0)
                        WriteLog(uid, 2, ip, "用户【" + name + "】，在广告管理功能中进行了数据修改操作，修改记录为【" + memo + "】。", MyCommand);
                }
                MyCommand.Parameters.Clear();
            }
            MyTrans.Commit();
            res = 1;
        }
        catch (Exception ex)
        {
            MyTrans.Rollback("Tran");
            res = -1;
        }
        Close();
        return res;
    }

    public int NewAd(string uid, string name, string ip, string ad_no)
    {
        int res = 0;
        Open();
        SqlCommand MyCommand = MyConnection.CreateCommand();
        SqlTransaction MyTrans = MyConnection.BeginTransaction("Tran");
        MyCommand.Connection = MyConnection;
        MyCommand.Transaction = MyTrans;
        try
        {
            string[] id = ad_no.Split(',');
            for (int i = 0; i < id.Length; i++)
            {
                MyCommand.CommandText = " select * from advertisement where ad_no=@ad_no ";
                MyCommand.Parameters.Add("@ad_no", SqlDbType.BigInt).Value = id[i];
                DataTable dt = new DataTable();
                SqlDataAdapter da = new SqlDataAdapter(MyCommand);
                da.Fill(dt);
                if (dt != null && dt.Rows.Count > 0)
                {
                    string memo = "广告：" + dt.Rows[0]["ad_title"].ToString() + "进行了刷新操作";
                    MyCommand.CommandText = "update advertisement set ad_inserttime=getdate() where ad_no=@ad_no ";
                    res = MyCommand.ExecuteNonQuery();
                    if (res > 0)
                        WriteLog(uid, 2, ip, "用户【" + name + "】，在广告管理功能中进行了数据修改操作，修改记录为【" + memo + "】。", MyCommand);
                }
                MyCommand.Parameters.Clear();
            }
            MyTrans.Commit();
            res = 1;
        }
        catch (Exception ex)
        {
            MyTrans.Rollback("Tran");
            res = -1;
        }
        Close();
        return res;
    }

    public Hashtable GetNews(string nw_no)
    {
        Open();
        SqlCommand MyCommand = new SqlCommand();
        MyCommand.Connection = MyConnection;

        MyCommand.CommandText = "select * from news where nw_no=@nw_no";
        MyCommand.Parameters.Add("@nw_no", SqlDbType.BigInt).Value = nw_no;
        DataTable data = new DataTable();
        SqlDataAdapter adapter = new SqlDataAdapter(MyCommand);
        adapter.Fill(data);
        Close();
        ArrayList da = DataTable2ArrayList(data);
        return da.Count > 0 ? (Hashtable)da[0] : null;
    }

    public int SaveNews(Hashtable data)
    {
        Int64 res;
        int ret = 0;
        Open();
        SqlCommand MyCommand = MyConnection.CreateCommand();
        SqlTransaction MyTrans;
        MyTrans = MyConnection.BeginTransaction("Tran");
        MyCommand.Connection = MyConnection;
        MyCommand.Transaction = MyTrans;
        try
        {
            MyCommand.Parameters.Add("@nw_type", SqlDbType.Int).Value = data["nw_type"];
            MyCommand.Parameters.Add("@nw_title", SqlDbType.NVarChar).Value = data["nw_title"];
            MyCommand.Parameters.Add("@nw_url", SqlDbType.NVarChar).Value = data["nw_url"];
            MyCommand.Parameters.Add("@nw_img", SqlDbType.NVarChar).Value = data["nw_img"];
            MyCommand.Parameters.Add("@nw_content", SqlDbType.NText).Value = data["nw_content"];
            MyCommand.Parameters.Add("@user", SqlDbType.NVarChar).Value = data["user"];
            MyCommand.Parameters.Add("@ip", SqlDbType.NVarChar).Value = data["ip"];
            if ("true".Equals(data["nw_hide"]))
                MyCommand.Parameters.Add("@nw_hide", SqlDbType.Int).Value = 1;
            else
                MyCommand.Parameters.Add("@nw_hide", SqlDbType.Int).Value = 0;
            if ("true".Equals(data["nw_red"]))
                MyCommand.Parameters.Add("@nw_red", SqlDbType.Int).Value = 1;
            else
                MyCommand.Parameters.Add("@nw_red", SqlDbType.Int).Value = 0;
            if ("true".Equals(data["nw_new"]))
                MyCommand.Parameters.Add("@nw_new", SqlDbType.Int).Value = 1;
            else
                MyCommand.Parameters.Add("@nw_new", SqlDbType.Int).Value = 0;

            if (string.IsNullOrEmpty(data["nw_no"].ToString()))
            {
                //MyCommand.CommandText = " select count(1) from news where nw_type=@nw_type and nw_title=@nw_title ";
                //int count = Convert.ToInt32(MyCommand.ExecuteScalar());
                //if (count == 0)
                //{
                string type = "";
                if ("11".Equals(data["nw_type"]))
                    type = "市场快讯";
                else if ("12".Equals(data["nw_type"]))
                    type = "热点招聘";
                else if ("13".Equals(data["nw_type"]))
                    type = "通知公告";
                else if ("14".Equals(data["nw_type"]))
                    type = "新闻资讯";
                else if ("15".Equals(data["nw_type"]))
                    type = "成绩公布";
                else if ("21".Equals(data["nw_type"]))
                    type = "服务介绍";
                else if ("22".Equals(data["nw_type"]))
                    type = "办事指南";
                else if ("31".Equals(data["nw_type"]))
                    type = "政策法规";
                else if ("32".Equals(data["nw_type"]))
                    type = "最新消息";
                else if ("33".Equals(data["nw_type"]))
                    type = "职称考试";
                else if ("34".Equals(data["nw_type"]))
                    type = "职称评审";
                else if ("35".Equals(data["nw_type"]))
                    type = "通知公告";
                else if ("36".Equals(data["nw_type"]))
                    type = "文件公布";
                else if ("37".Equals(data["nw_type"]))
                    type = "表格下载";
                else if ("38".Equals(data["nw_type"]))
                    type = "业务指南";
                else if ("41".Equals(data["nw_type"]))
                    type = "通知公告";
                else if ("42".Equals(data["nw_type"]))
                    type = "情况通报";
                else if ("43".Equals(data["nw_type"]))
                    type = "时政快递";
                else if ("44".Equals(data["nw_type"]))
                    type = "网上党校";
                else if ("45".Equals(data["nw_type"]))
                    type = "学习园地";
                else if ("46".Equals(data["nw_type"]))
                    type = "党员风采";
                else if ("47".Equals(data["nw_type"]))
                    type = "支部活动";
                else if ("48".Equals(data["nw_type"]))
                    type = "办事指南";
                else if ("51".Equals(data["nw_type"]))
                    type = "服务介绍";
                else if ("52".Equals(data["nw_type"]))
                    type = "办事指南";
                else if ("53".Equals(data["nw_type"]))
                    type = "通知公告";
                else if ("61".Equals(data["nw_type"]))
                    type = "就业政策";
                else if ("62".Equals(data["nw_type"]))
                    type = "就业指导";
                else if ("63".Equals(data["nw_type"]))
                    type = "办事指南";
                else if ("70".Equals(data["nw_type"]))
                    type = "图片新闻";
                else if ("71".Equals(data["nw_type"]))
                    type = "协会简介";
                else if ("72".Equals(data["nw_type"]))
                    type = "入会申请";
                else if ("73".Equals(data["nw_type"]))
                    type = "协会章程";
                else if ("74".Equals(data["nw_type"]))
                    type = "选举办法";
                else if ("75".Equals(data["nw_type"]))
                    type = "组织结构";
                else if ("76".Equals(data["nw_type"]))
                    type = "通知公告";
                else if ("77".Equals(data["nw_type"]))
                    type = "协会动态";
                else if ("78".Equals(data["nw_type"]))
                    type = "经验交流";
                else if ("79".Equals(data["nw_type"]))
                    type = "常务理事";
                else if ("710".Equals(data["nw_type"]))
                    type = "缴费办法";
                else if ("81".Equals(data["nw_type"]))
                    type = "湖州简介";
                else if ("82".Equals(data["nw_type"]))
                    type = "工作动态";
                else if ("83".Equals(data["nw_type"]))
                    type = "政策文件";
                else if ("84".Equals(data["nw_type"]))
                    type = "创业平台";
                else if ("85".Equals(data["nw_type"]))
                    type = "人才需求";
                if (!"true".Equals(data["nw_orderid"]))
                    MyCommand.CommandText = " insert into news (nw_title,nw_type,nw_orderid,nw_red,nw_hide,nw_new,nw_url,nw_img,nw_content,nw_hits,nw_inserttime,nw_insertip,nw_insertuser,nw_modifytime,nw_modifyip,nw_modifyuser) values (@nw_title,@nw_type,0,@nw_red,@nw_hide,@nw_new,@nw_url,@nw_img,@nw_content,0,getdate(),@ip,@user,getdate(),@ip,@user);select @@Identity ";
                else
                    MyCommand.CommandText = " insert into news select @nw_title,@nw_type,isnull(MAX(nw_orderid),0)+1,@nw_red,@nw_hide,@nw_new,@nw_url,@nw_img,@nw_content,0,getdate(),@ip,@user,getdate(),@ip,@user,null from news;select @@Identity ";
                res = Convert.ToInt64(MyCommand.ExecuteScalar());
                //res = MyCommand.ExecuteNonQuery();
                string str = data["nw_content"].ToString();
                while (str.Contains("/upload/file/"))
                {
                    string f = str.Substring(str.IndexOf("/upload/file/") - 1, 1);
                    str = str.Substring(str.IndexOf("/upload/file/"));
                    string url = str.Substring(str.IndexOf("/upload/file/"), str.IndexOf(f));
                    str = str.Substring(str.IndexOf(f) + 1);
                    MyCommand.CommandText = " update uploadfile set uf_nwno=@uf_nwno,uf_type=1 where uf_url=@uf_url ";
                    MyCommand.Parameters.Add("@uf_nwno", SqlDbType.BigInt).Value = res;
                    MyCommand.Parameters.Add("@uf_url", SqlDbType.NVarChar).Value = url;
                    MyCommand.ExecuteNonQuery();
                    MyCommand.Parameters.Clear();
                }
                if (res > 0)
                {
                    ret = 1;
                    WriteLog(data["user"].ToString(), 1, data["ip"].ToString(), "用户【" + data["name"].ToString() + "】，在资讯管理功能中进行了数据新增操作，新增记录为【资讯类型：" + type + "，标题：" + data["nw_title"] + "】。", MyCommand);
                }
                else
                    ret = -1;
                //}
                //else
                //    ret = 2;
            }
            else
            {
                //MyCommand.CommandText = " select count(1) from news where nw_no<>@nw_no and nw_type=@nw_type and nw_title=@nw_title ";
                MyCommand.Parameters.Add("@nw_no", SqlDbType.BigInt).Value = data["nw_no"];
                //int count = Convert.ToInt32(MyCommand.ExecuteScalar());
                //if (count == 0)
                //{
                MyCommand.CommandText = " select * from news where nw_no=@nw_no ";
                DataTable dt = new DataTable();
                SqlDataAdapter da = new SqlDataAdapter(MyCommand);
                da.Fill(dt);
                if (dt != null && dt.Rows.Count > 0)
                {
                    string memo = "";
                    if (!data["nw_title"].ToString().Equals(dt.Rows[0]["nw_title"].ToString()))
                        memo = "资讯：" + dt.Rows[0]["nw_title"].ToString() + "，将标题从[" + dt.Rows[0]["nw_title"].ToString() + "]改为[" + data["ad_title"] + "]";
                    if (!data["nw_type"].ToString().Equals(dt.Rows[0]["nw_type"].ToString()))
                    {
                        string type1 = "";
                        if ("11".Equals(dt.Rows[0]["nw_type"].ToString()))
                            type1 = "市场快讯";
                        else if ("12".Equals(dt.Rows[0]["nw_type"].ToString()))
                            type1 = "热点招聘";
                        else if ("13".Equals(dt.Rows[0]["nw_type"].ToString()))
                            type1 = "通知公告";
                        else if ("14".Equals(dt.Rows[0]["nw_type"].ToString()))
                            type1 = "新闻资讯";
                        else if ("15".Equals(dt.Rows[0]["nw_type"].ToString()))
                            type1 = "成绩公布";
                        else if ("21".Equals(dt.Rows[0]["nw_type"].ToString()))
                            type1 = "服务介绍";
                        else if ("22".Equals(dt.Rows[0]["nw_type"].ToString()))
                            type1 = "办事指南";
                        else if ("31".Equals(dt.Rows[0]["nw_type"].ToString()))
                            type1 = "政策法规";
                        else if ("32".Equals(dt.Rows[0]["nw_type"].ToString()))
                            type1 = "最新消息";
                        else if ("33".Equals(dt.Rows[0]["nw_type"].ToString()))
                            type1 = "职称考试";
                        else if ("34".Equals(dt.Rows[0]["nw_type"].ToString()))
                            type1 = "职称评审";
                        else if ("35".Equals(dt.Rows[0]["nw_type"].ToString()))
                            type1 = "通知公告";
                        else if ("36".Equals(dt.Rows[0]["nw_type"].ToString()))
                            type1 = "文件公布";
                        else if ("37".Equals(dt.Rows[0]["nw_type"].ToString()))
                            type1 = "表格下载";
                        else if ("38".Equals(dt.Rows[0]["nw_type"].ToString()))
                            type1 = "业务指南";
                        else if ("41".Equals(dt.Rows[0]["nw_type"].ToString()))
                            type1 = "通知公告";
                        else if ("42".Equals(dt.Rows[0]["nw_type"].ToString()))
                            type1 = "情况通报";
                        else if ("43".Equals(dt.Rows[0]["nw_type"].ToString()))
                            type1 = "时政快递";
                        else if ("44".Equals(dt.Rows[0]["nw_type"].ToString()))
                            type1 = "网上党校";
                        else if ("45".Equals(dt.Rows[0]["nw_type"].ToString()))
                            type1 = "学习园地";
                        else if ("46".Equals(dt.Rows[0]["nw_type"].ToString()))
                            type1 = "党员风采";
                        else if ("47".Equals(dt.Rows[0]["nw_type"].ToString()))
                            type1 = "支部活动";
                        else if ("48".Equals(dt.Rows[0]["nw_type"].ToString()))
                            type1 = "办事指南";
                        else if ("51".Equals(dt.Rows[0]["nw_type"].ToString()))
                            type1 = "服务介绍";
                        else if ("52".Equals(dt.Rows[0]["nw_type"].ToString()))
                            type1 = "办事指南";
                        else if ("53".Equals(dt.Rows[0]["nw_type"].ToString()))
                            type1 = "通知公告";
                        else if ("61".Equals(dt.Rows[0]["nw_type"].ToString()))
                            type1 = "就业政策";
                        else if ("62".Equals(dt.Rows[0]["nw_type"].ToString()))
                            type1 = "就业指导";
                        else if ("63".Equals(dt.Rows[0]["nw_type"].ToString()))
                            type1 = "办事指南";
                        else if ("70".Equals(dt.Rows[0]["nw_type"].ToString()))
                            type1 = "图片新闻";
                        else if ("71".Equals(dt.Rows[0]["nw_type"].ToString()))
                            type1 = "协会简介";
                        else if ("72".Equals(dt.Rows[0]["nw_type"].ToString()))
                            type1 = "入会申请";
                        else if ("73".Equals(dt.Rows[0]["nw_type"].ToString()))
                            type1 = "协会章程";
                        else if ("74".Equals(dt.Rows[0]["nw_type"].ToString()))
                            type1 = "选举办法";
                        else if ("75".Equals(dt.Rows[0]["nw_type"].ToString()))
                            type1 = "组织结构";
                        else if ("76".Equals(dt.Rows[0]["nw_type"].ToString()))
                            type1 = "通知公告";
                        else if ("77".Equals(dt.Rows[0]["nw_type"].ToString()))
                            type1 = "协会动态";
                        else if ("78".Equals(dt.Rows[0]["nw_type"].ToString()))
                            type1 = "经验交流";
                        else if ("79".Equals(dt.Rows[0]["nw_type"].ToString()))
                            type1 = "常务理事";
                        else if ("710".Equals(dt.Rows[0]["nw_type"].ToString()))
                            type1 = "缴费办法";
                        else if ("81".Equals(dt.Rows[0]["nw_type"].ToString()))
                            type1 = "湖州简介";
                        else if ("82".Equals(dt.Rows[0]["nw_type"].ToString()))
                            type1 = "工作动态";
                        else if ("83".Equals(dt.Rows[0]["nw_type"].ToString()))
                            type1 = "政策文件";
                        else if ("84".Equals(dt.Rows[0]["nw_type"].ToString()))
                            type1 = "创业平台";
                        else if ("85".Equals(dt.Rows[0]["nw_type"].ToString()))
                            type1 = "人才需求";
                        string type2 = "";
                        if ("11".Equals(data["nw_type"]))
                            type2 = "市场快讯";
                        else if ("12".Equals(data["nw_type"]))
                            type2 = "热点招聘";
                        else if ("13".Equals(data["nw_type"]))
                            type2 = "通知公告";
                        else if ("14".Equals(data["nw_type"]))
                            type2 = "新闻资讯";
                        else if ("15".Equals(data["nw_type"]))
                            type2 = "成绩公布";
                        else if ("21".Equals(data["nw_type"]))
                            type2 = "服务介绍";
                        else if ("22".Equals(data["nw_type"]))
                            type2 = "办事指南";
                        else if ("31".Equals(data["nw_type"]))
                            type2 = "政策法规";
                        else if ("32".Equals(data["nw_type"]))
                            type2 = "最新消息";
                        else if ("33".Equals(data["nw_type"]))
                            type2 = "职称考试";
                        else if ("34".Equals(data["nw_type"]))
                            type2 = "职称评审";
                        else if ("35".Equals(data["nw_type"]))
                            type2 = "通知公告";
                        else if ("36".Equals(data["nw_type"]))
                            type2 = "文件公布";
                        else if ("37".Equals(data["nw_type"]))
                            type2 = "表格下载";
                        else if ("38".Equals(data["nw_type"]))
                            type2 = "业务指南";
                        else if ("41".Equals(data["nw_type"]))
                            type2 = "通知公告";
                        else if ("42".Equals(data["nw_type"]))
                            type2 = "情况通报";
                        else if ("43".Equals(data["nw_type"]))
                            type2 = "时政快递";
                        else if ("44".Equals(data["nw_type"]))
                            type2 = "网上党校";
                        else if ("45".Equals(data["nw_type"]))
                            type2 = "学习园地";
                        else if ("46".Equals(data["nw_type"]))
                            type2 = "党员风采";
                        else if ("47".Equals(data["nw_type"]))
                            type2 = "支部活动";
                        else if ("48".Equals(data["nw_type"]))
                            type2 = "办事指南";
                        else if ("51".Equals(data["nw_type"]))
                            type2 = "服务介绍";
                        else if ("52".Equals(data["nw_type"]))
                            type2 = "办事指南";
                        else if ("53".Equals(data["nw_type"]))
                            type2 = "通知公告";
                        else if ("61".Equals(data["nw_type"]))
                            type2 = "就业政策";
                        else if ("62".Equals(data["nw_type"]))
                            type2 = "就业指导";
                        else if ("63".Equals(data["nw_type"]))
                            type2 = "办事指南";
                        else if ("70".Equals(data["nw_type"]))
                            type2 = "图片新闻";
                        else if ("71".Equals(data["nw_type"]))
                            type2 = "协会简介";
                        else if ("72".Equals(data["nw_type"]))
                            type2 = "入会申请";
                        else if ("73".Equals(data["nw_type"]))
                            type2 = "协会章程";
                        else if ("74".Equals(data["nw_type"]))
                            type2 = "选举办法";
                        else if ("75".Equals(data["nw_type"]))
                            type2 = "组织结构";
                        else if ("76".Equals(data["nw_type"]))
                            type2 = "通知公告";
                        else if ("77".Equals(data["nw_type"]))
                            type2 = "协会动态";
                        else if ("78".Equals(data["nw_type"]))
                            type2 = "经验交流";
                        else if ("79".Equals(data["nw_type"]))
                            type2 = "常务理事";
                        else if ("710".Equals(data["nw_type"]))
                            type2 = "缴费办法";
                        else if ("81".Equals(data["nw_type"]))
                            type2 = "湖州简介";
                        else if ("82".Equals(data["nw_type"]))
                            type2 = "工作动态";
                        else if ("83".Equals(data["nw_type"]))
                            type2 = "政策文件";
                        else if ("84".Equals(data["nw_type"]))
                            type2 = "创业平台";
                        else if ("85".Equals(data["nw_type"]))
                            type2 = "人才需求";
                        if (string.IsNullOrEmpty(memo))
                            memo = "资讯：" + dt.Rows[0]["nw_title"].ToString() + "，将资讯类型从[" + type1 + "]改为[" + type2 + "]";
                        else
                            memo += "；将资讯类型从[" + type1 + "]改为[" + type2 + "]";
                    }
                    if (("true".Equals(data["nw_hide"]) && "0".Equals(dt.Rows[0]["nw_hide"].ToString())) || ("false".Equals(data["nw_hide"]) && "1".Equals(dt.Rows[0]["nw_hide"].ToString())))
                    {
                        string s1 = "显示";
                        if (ConfigurationManager.AppSettings["Close"].Equals(dt.Rows[0]["nw_hide"].ToString()))
                            s1 = "隐藏";
                        string s2 = "显示";
                        if (("true".Equals(data["nw_hide"])))
                            s2 = "隐藏";
                        if (string.IsNullOrEmpty(memo))
                            memo = "资讯：" + dt.Rows[0]["nw_title"].ToString() + "，将状态从[" + s1 + "]改为[" + s2 + "]";
                        else
                            memo += "；将状态从[" + s1 + "]改为[" + s2 + "]";
                    }
                    if (("true".Equals(data["nw_orderid"]) && ("0".Equals(dt.Rows[0]["nw_orderid"].ToString()))) || ("false".Equals(data["nw_orderid"]) && (!"0".Equals(dt.Rows[0]["nw_orderid"].ToString()))))
                    {
                        string s1 = "置顶";
                        if (ConfigurationManager.AppSettings["NoTop"].Equals(dt.Rows[0]["nw_orderid"].ToString()))
                            s1 = "不置顶";
                        string s2 = "置顶";
                        if (("false".Equals(data["nw_orderid"])))
                            s2 = "不置顶";
                        if (string.IsNullOrEmpty(memo))
                            memo = "资讯：" + dt.Rows[0]["nw_title"].ToString() + "，将置顶从[" + s1 + "]改为[" + s2 + "]";
                        else
                            memo += "；将置顶从[" + s1 + "]改为[" + s2 + "]";
                    }
                    if (("true".Equals(data["nw_red"]) && "0".Equals(dt.Rows[0]["nw_red"].ToString())) || ("false".Equals(data["nw_red"]) && "1".Equals(dt.Rows[0]["nw_red"].ToString())))
                    {
                        string s1 = "描红";
                        if (ConfigurationManager.AppSettings["StateDisable"].Equals(dt.Rows[0]["nw_red"].ToString()))
                            s1 = "不描红";
                        string s2 = "描红";
                        if (("false".Equals(data["nw_red"])))
                            s2 = "不描红";
                        if (string.IsNullOrEmpty(memo))
                            memo = "资讯：" + dt.Rows[0]["nw_title"].ToString() + "，设置描红从[" + s1 + "]改为[" + s2 + "]";
                        else
                            memo += "；将描红从[" + s1 + "]改为[" + s2 + "]";
                    }
                    if (("true".Equals(data["nw_new"]) && "0".Equals(dt.Rows[0]["nw_new"].ToString())) || ("false".Equals(data["nw_new"]) && "1".Equals(dt.Rows[0]["nw_new"].ToString())))
                    {
                        string s1 = "最新";
                        if (ConfigurationManager.AppSettings["StateDisable"].Equals(dt.Rows[0]["nw_new"].ToString()))
                            s1 = "不最新";
                        string s2 = "最新";
                        if (("false".Equals(data["nw_new"])))
                            s2 = "不最新";
                        if (string.IsNullOrEmpty(memo))
                            memo = "资讯：" + dt.Rows[0]["nw_title"].ToString() + "，将最新从[" + s1 + "]改为[" + s2 + "]";
                        else
                            memo += "；将最新从[" + s1 + "]改为[" + s2 + "]";
                    }
                    if (!data["nw_url"].ToString().Equals(dt.Rows[0]["nw_url"].ToString()))
                    {
                        if (string.IsNullOrEmpty(memo))
                            memo = "资讯：" + dt.Rows[0]["nw_title"].ToString() + "，将引用地址从[" + dt.Rows[0]["nw_url"].ToString() + "]改为[" + data["nw_url"] + "]";
                        else
                            memo += "；将引用地址从[" + dt.Rows[0]["nw_url"].ToString() + "]改为[" + data["nw_url"] + "]";
                    }
                    if (!data["nw_img"].ToString().Equals(dt.Rows[0]["nw_img"].ToString()))
                    {
                        if (string.IsNullOrEmpty(memo))
                            memo = "资讯：" + dt.Rows[0]["nw_title"].ToString() + "，将图片从[" + dt.Rows[0]["nw_img"].ToString() + "]改为[" + data["nw_img"] + "]";
                        else
                            memo += "；将图片从[" + dt.Rows[0]["nw_img"].ToString() + "]改为[" + data["nw_img"] + "]";
                    }
                    if (!data["nw_content"].ToString().Equals(dt.Rows[0]["nw_content"].ToString()))
                    {
                        if (string.IsNullOrEmpty(memo))
                            memo = "资讯：" + dt.Rows[0]["nw_title"].ToString() + "，将内容进行了修改";
                        else
                            memo += "；将内容进行了修改";
                    }
                    if (string.IsNullOrEmpty(memo))
                        memo = "资讯：" + dt.Rows[0]["nw_title"].ToString() + "，未修改任何字段";
                    if (!"true".Equals(data["nw_orderid"]))
                        MyCommand.CommandText = " update news set nw_title=@nw_title,nw_type=@nw_type,nw_orderid=0,nw_red=@nw_red,nw_hide=@nw_hide,nw_new=@nw_new,nw_url=@nw_url,nw_img=@nw_img,nw_content=@nw_content,nw_modifytime=getdate(),nw_modifyip=@ip,nw_modifyuser=@user where nw_no=@nw_no ";
                    else if ("true".Equals(data["nw_orderid"]) && !"0".Equals(dt.Rows[0]["nw_orderid"].ToString()))
                        MyCommand.CommandText = " update news set nw_title=@nw_title,nw_type=@nw_type,nw_red=@nw_red,nw_hide=@nw_hide,nw_new=@nw_new,nw_url=@nw_url,nw_img=@nw_img,nw_content=@nw_content,nw_modifytime=getdate(),nw_modifyip=@ip,nw_modifyuser=@user where nw_no=@nw_no ";
                    else
                        MyCommand.CommandText = " update news set nw_title=@nw_title,nw_type=@nw_type,nw_orderid=(select MAX(nw_orderid) + 1 from news),nw_red=@nw_red,nw_hide=@nw_hide,nw_new=@nw_new,nw_url=@nw_url,nw_img=@nw_img,nw_content=@nw_content,nw_modifytime=getdate(),nw_modifyip=@ip,nw_modifyuser=@user where nw_no=@nw_no ";
                    res = MyCommand.ExecuteNonQuery();
                    string str = data["nw_content"].ToString();
                    while (str.Contains("/upload/file/"))
                    {
                        string f = str.Substring(str.IndexOf("/upload/file/") - 1, 1);
                        str = str.Substring(str.IndexOf("/upload/file/"));
                        string url = str.Substring(str.IndexOf("/upload/file/"), str.IndexOf(f));
                        str = str.Substring(str.IndexOf(f) + 1);
                        MyCommand.CommandText = " update uploadfile set uf_nwno=@uf_nwno,uf_type=1 where uf_url=@uf_url ";
                        MyCommand.Parameters.Add("@uf_nwno", SqlDbType.BigInt).Value = data["nw_no"];
                        MyCommand.Parameters.Add("@uf_url", SqlDbType.NVarChar).Value = url;
                        MyCommand.ExecuteNonQuery();
                        MyCommand.Parameters.Clear();
                    }
                    if (res > 0)
                    {
                        ret = 1;
                        WriteLog(data["user"].ToString(), 2, data["ip"].ToString(), "用户【" + data["name"].ToString() + "】，在资讯管理功能中进行了数据修改操作，修改记录为【" + memo + "】。", MyCommand);
                    }
                    else
                        ret = 0;
                }
                else
                    ret = 0;
                //}
                //else
                //    ret = 2;
            }
            MyTrans.Commit();
        }
        catch
        {
            MyTrans.Rollback("Tran");
            ret = -1;
        }
        Close();
        return ret;
    }

    public Int64 SaveFile(Hashtable data)
    {
        Int64 res;
        Open();
        SqlCommand MyCommand = MyConnection.CreateCommand();
        SqlTransaction MyTrans;
        MyTrans = MyConnection.BeginTransaction("Tran");
        MyCommand.Connection = MyConnection;
        MyCommand.Transaction = MyTrans;
        try
        {
            MyCommand.Parameters.Add("@uf_url", SqlDbType.NVarChar).Value = data["url"];
            if (string.IsNullOrEmpty(data["time"].ToString()))
                MyCommand.Parameters.Add("@uf_time", SqlDbType.DateTime).Value = DBNull.Value;
            else
                MyCommand.Parameters.Add("@uf_time", SqlDbType.DateTime).Value = data["time"];

            MyCommand.CommandText = " insert into uploadfile(uf_url,uf_time) values(@uf_url,@uf_time);select @@Identity ";
            res = Convert.ToInt64(MyCommand.ExecuteScalar());
            MyTrans.Commit();
        }
        catch
        {
            MyTrans.Rollback("Tran");
            res = -1;
        }
        Close();
        return res;
    }

    public int SaveFile2(Hashtable data)
    {
        int res;
        Open();
        SqlCommand MyCommand = MyConnection.CreateCommand();
        SqlTransaction MyTrans;
        MyTrans = MyConnection.BeginTransaction("Tran");
        MyCommand.Connection = MyConnection;
        MyCommand.Transaction = MyTrans;
        try
        {
            MyCommand.Parameters.Add("@nw_type", SqlDbType.Int).Value = data["nw_type"];
            MyCommand.Parameters.Add("@nw_title", SqlDbType.NVarChar).Value = data["nw_title"];
            MyCommand.Parameters.Add("@nw_url", SqlDbType.NVarChar).Value = data["nw_url"];
            MyCommand.Parameters.Add("@nw_img", SqlDbType.NVarChar).Value = data["nw_img"];
            MyCommand.Parameters.Add("@nw_content", SqlDbType.NText).Value = data["nw_content"];
            if (string.IsNullOrEmpty(data["nw_uploadtime"].ToString()))
                MyCommand.Parameters.Add("@nw_uploadtime", SqlDbType.DateTime).Value = DBNull.Value;
            else
                MyCommand.Parameters.Add("@nw_uploadtime", SqlDbType.DateTime).Value = data["nw_uploadtime"];
            MyCommand.Parameters.Add("@user", SqlDbType.NVarChar).Value = data["user"];
            MyCommand.Parameters.Add("@ip", SqlDbType.NVarChar).Value = data["ip"];
            if ("true".Equals(data["nw_hide"]))
                MyCommand.Parameters.Add("@nw_hide", SqlDbType.Int).Value = 1;
            else
                MyCommand.Parameters.Add("@nw_hide", SqlDbType.Int).Value = 0;
            if ("true".Equals(data["nw_red"]))
                MyCommand.Parameters.Add("@nw_red", SqlDbType.Int).Value = 1;
            else
                MyCommand.Parameters.Add("@nw_red", SqlDbType.Int).Value = 0;
            if ("true".Equals(data["nw_new"]))
                MyCommand.Parameters.Add("@nw_new", SqlDbType.Int).Value = 1;
            else
                MyCommand.Parameters.Add("@nw_new", SqlDbType.Int).Value = 0;

            if (string.IsNullOrEmpty(data["nw_no"].ToString()))
            {
                MyCommand.CommandText = " select count(1) from news where nw_type=@nw_type and nw_title=@nw_title ";
                int count = Convert.ToInt32(MyCommand.ExecuteScalar());
                if (count == 0)
                {
                    string type = "";
                    if ("11".Equals(data["nw_type"]))
                        type = "市场快讯";
                    else if ("13".Equals(data["nw_type"]))
                        type = "通知公告";
                    else if ("3".Equals(data["nw_type"]))
                        type = "导航条下侧通栏广告";
                    else if ("4".Equals(data["nw_type"]))
                        type = "搜索栏下侧通栏广告";
                    else if ("5".Equals(data["nw_type"]))
                        type = "VIP招聘下侧通栏广告";
                    else if ("6".Equals(data["nw_type"]))
                        type = "左右两侧挂边广告";
                    if (!"true".Equals(data["nw_orderid"]))
                        MyCommand.CommandText = " insert into news (nw_title,nw_type,nw_orderid,nw_red,nw_hide,nw_new,nw_url,nw_img,nw_content,nw_hits,nw_uploadtime,nw_inserttime,nw_insertip,nw_insertuser) values (@nw_title,@nw_type,0,@nw_red,@nw_hide,@nw_new,@nw_url,@nw_img,@nw_content,0,@nw_uploadtime,getdate(),@ip,@user) ";
                    else
                        MyCommand.CommandText = " insert into news select @nw_title,@nw_type,isnull(MAX(nw_orderid),0)+1,@nw_red,@nw_hide,@nw_new,@nw_url,@nw_img,@nw_content,0,getdate(),@ip,@user,null,null,null,@nw_uploadtime from news ";
                    res = MyCommand.ExecuteNonQuery();
                    if (res > 0)
                        WriteLog(data["user"].ToString(), 1, data["ip"].ToString(), "用户【" + data["name"].ToString() + "】，在资讯管理功能中进行了数据新增操作，新增记录为【资讯类型：" + type + "，标题：" + data["nw_title"] + "】。", MyCommand);
                    else
                        res = -1;
                }
                else
                    res = 2;
            }
            else
            {
                MyCommand.CommandText = " select count(1) from news where nw_no<>@nw_no and nw_type=@nw_type and nw_title=@nw_title ";
                MyCommand.Parameters.Add("@nw_no", SqlDbType.BigInt).Value = data["nw_no"];
                int count = Convert.ToInt32(MyCommand.ExecuteScalar());
                if (count == 0)
                {
                    MyCommand.CommandText = " select * from news where nw_no=@nw_no ";
                    DataTable dt = new DataTable();
                    SqlDataAdapter da = new SqlDataAdapter(MyCommand);
                    da.Fill(dt);
                    if (dt != null && dt.Rows.Count > 0)
                    {
                        string memo = "";
                        if (!data["nw_title"].ToString().Equals(dt.Rows[0]["nw_title"].ToString()))
                            memo = "资讯：" + dt.Rows[0]["nw_title"].ToString() + "，将标题从[" + dt.Rows[0]["nw_title"].ToString() + "]改为[" + data["ad_title"] + "]";
                        if (!data["nw_type"].ToString().Equals(dt.Rows[0]["nw_type"].ToString()))
                        {
                            string type1 = "";
                            if ("11".Equals(data["nw_type"]))
                                type1 = "市场快讯";
                            else if ("13".Equals(data["nw_type"]))
                                type1 = "通知公告";
                            else if ("3".Equals(data["nw_type"]))
                                type1 = "导航条下侧通栏广告";
                            else if ("4".Equals(data["nw_type"]))
                                type1 = "搜索栏下侧通栏广告";
                            else if ("5".Equals(data["nw_type"]))
                                type1 = "VIP招聘下侧通栏广告";
                            else if ("6".Equals(data["nw_type"]))
                                type1 = "左右两侧挂边广告";
                            string type2 = "";
                            if ("11".Equals(data["nw_type"]))
                                type2 = "市场快讯";
                            else if ("13".Equals(data["nw_type"]))
                                type2 = "通知公告";
                            else if ("3".Equals(data["nw_type"]))
                                type2 = "导航条下侧通栏广告";
                            else if ("4".Equals(data["nw_type"]))
                                type2 = "搜索栏下侧通栏广告";
                            else if ("5".Equals(data["nw_type"]))
                                type2 = "VIP招聘下侧通栏广告";
                            else if ("6".Equals(data["nw_type"]))
                                type2 = "左右两侧挂边广告";
                            if (string.IsNullOrEmpty(memo))
                                memo = "资讯：" + dt.Rows[0]["nw_title"].ToString() + "，将资讯类型从[" + type1 + "]改为[" + type2 + "]";
                            else
                                memo += "；将资讯类型从[" + type1 + "]改为[" + type2 + "]";
                        }
                        if (!data["nw_hide"].ToString().Equals(dt.Rows[0]["nw_hide"].ToString()))
                        {
                            string s1 = "显示";
                            if (ConfigurationManager.AppSettings["Close"].Equals(dt.Rows[0]["nw_hide"].ToString()))
                                s1 = "隐藏";
                            string s2 = "显示";
                            if (ConfigurationManager.AppSettings["Close"].Equals(data["nw_hide"].ToString()))
                                s2 = "隐藏";
                            if (string.IsNullOrEmpty(memo))
                                memo = "资讯：" + dt.Rows[0]["nw_title"].ToString() + "，将状态从[" + s1 + "]改为[" + s2 + "]";
                            else
                                memo += "；将状态从[" + s1 + "]改为[" + s2 + "]";
                        }
                        if (!data["nw_orderid"].ToString().Equals(dt.Rows[0]["nw_orderid"].ToString()) && ("0".Equals(data["nw_orderid"].ToString()) || "0".Equals(dt.Rows[0]["nw_orderid"].ToString())))
                        {
                            string s1 = "置顶";
                            if (ConfigurationManager.AppSettings["NoTop"].Equals(dt.Rows[0]["nw_orderid"].ToString()))
                                s1 = "不置顶";
                            string s2 = "置顶";
                            if (ConfigurationManager.AppSettings["NoTop"].Equals(data["nw_orderid"].ToString()))
                                s2 = "不置顶";
                            if (string.IsNullOrEmpty(memo))
                                memo = "资讯：" + dt.Rows[0]["nw_title"].ToString() + "，将置顶从[" + s1 + "]改为[" + s2 + "]";
                            else
                                memo += "；将置顶从[" + s1 + "]改为[" + s2 + "]";
                        }
                        if (!data["nw_red"].ToString().Equals(dt.Rows[0]["nw_red"].ToString()))
                        {
                            string s1 = "描红";
                            if (ConfigurationManager.AppSettings["StateDisable"].Equals(dt.Rows[0]["nw_red"].ToString()))
                                s1 = "不描红";
                            string s2 = "描红";
                            if (ConfigurationManager.AppSettings["StateDisable"].Equals(data["nw_red"].ToString()))
                                s2 = "不描红";
                            if (string.IsNullOrEmpty(memo))
                                memo = "资讯：" + dt.Rows[0]["nw_title"].ToString() + "，设置描红从[" + s1 + "]改为[" + s2 + "]";
                            else
                                memo += "；将描红从[" + s1 + "]改为[" + s2 + "]";
                        }
                        if (!data["nw_new"].ToString().Equals(dt.Rows[0]["nw_new"].ToString()))
                        {
                            string s1 = "最新";
                            if (ConfigurationManager.AppSettings["StateDisable"].Equals(dt.Rows[0]["nw_new"].ToString()))
                                s1 = "不最新";
                            string s2 = "最新";
                            if (ConfigurationManager.AppSettings["StateDisable"].Equals(data["nw_new"].ToString()))
                                s2 = "不最新";
                            if (string.IsNullOrEmpty(memo))
                                memo = "资讯：" + dt.Rows[0]["nw_title"].ToString() + "，将最新从[" + s1 + "]改为[" + s2 + "]";
                            else
                                memo += "；将最新从[" + s1 + "]改为[" + s2 + "]";
                        }
                        if (!data["nw_url"].ToString().Equals(dt.Rows[0]["nw_url"].ToString()))
                        {
                            if (string.IsNullOrEmpty(memo))
                                memo = "资讯：" + dt.Rows[0]["nw_title"].ToString() + "，将引用地址从[" + dt.Rows[0]["nw_url"].ToString() + "]改为[" + data["nw_url"] + "]";
                            else
                                memo += "；将引用地址从[" + dt.Rows[0]["nw_url"].ToString() + "]改为[" + data["nw_url"] + "]";
                        }
                        if (!data["nw_img"].ToString().Equals(dt.Rows[0]["nw_img"].ToString()))
                        {
                            if (string.IsNullOrEmpty(memo))
                                memo = "资讯：" + dt.Rows[0]["nw_title"].ToString() + "，将文件从[" + dt.Rows[0]["nw_img"].ToString() + "]改为[" + data["nw_img"] + "]";
                            else
                                memo += "；将文件从[" + dt.Rows[0]["nw_img"].ToString() + "]改为[" + data["nw_img"] + "]";
                        }
                        if (!data["nw_content"].ToString().Equals(dt.Rows[0]["nw_content"].ToString()))
                        {
                            if (string.IsNullOrEmpty(memo))
                                memo = "资讯：" + dt.Rows[0]["nw_title"].ToString() + "，将内容进行了修改";
                            else
                                memo += "；将内容进行了修改";
                        }
                        if (!data["nw_uploadtime"].ToString().Equals(dt.Rows[0]["nw_uploadtime"].ToString()))
                        {
                            if (string.IsNullOrEmpty(memo))
                                memo = "资讯：" + dt.Rows[0]["nw_title"].ToString() + "，将文件上传时间从[" + dt.Rows[0]["nw_uploadtime"].ToString() + "]改为[" + data["nw_uploadtime"] + "]";
                            else
                                memo += "；将文件上传时间从[" + dt.Rows[0]["nw_uploadtime"].ToString() + "]改为[" + data["nw_uploadtime"] + "]";
                        }
                        if (string.IsNullOrEmpty(memo))
                            memo = "资讯：" + dt.Rows[0]["nw_title"].ToString() + "，未修改任何字段";
                        if (!"true".Equals(data["nw_orderid"]))
                            MyCommand.CommandText = " update news set nw_title=@nw_title,nw_type=@nw_type,nw_orderid=0,nw_red=@nw_red,nw_hide=@nw_hide,nw_new=@nw_new,nw_url=@nw_url,nw_img=@nw_img,nw_content=@nw_content,nw_uploadtime=@nw_uploadtime,nw_modifytime=getdate(),nw_modifyip=@ip,nw_modifyuser=@user where nw_no=@nw_no ";
                        else if ("true".Equals(data["nw_orderid"]) && !"0".Equals(dt.Rows[0]["nw_orderid"].ToString()))
                            MyCommand.CommandText = " update news set nw_title=@nw_title,nw_type=@nw_type,nw_red=@nw_red,nw_hide=@nw_hide,nw_new=@nw_new,nw_url=@nw_url,nw_img=@nw_img,nw_content=@nw_content,nw_uploadtime=@nw_uploadtime,nw_modifytime=getdate(),nw_modifyip=@ip,nw_modifyuser=@user where nw_no=@nw_no ";
                        else
                            MyCommand.CommandText = " update news set nw_title=@nw_title,nw_type=@nw_type,nw_orderid=(select MAX(nw_orderid) + 1 from news),nw_red=@nw_red,nw_hide=@nw_hide,nw_new=@nw_new,nw_url=@nw_url,nw_img=@nw_img,nw_content=@nw_content,nw_uploadtime=@nw_uploadtime,nw_modifytime=getdate(),nw_modifyip=@ip,nw_modifyuser=@user where nw_no=@nw_no ";
                        res = MyCommand.ExecuteNonQuery();
                        if (res > 0)
                            WriteLog(data["user"].ToString(), 2, data["ip"].ToString(), "用户【" + data["name"].ToString() + "】，在资讯管理功能中进行了数据修改操作，修改记录为【" + memo + "】。", MyCommand);
                    }
                    else
                        res = 0;
                }
                else
                    res = 2;
            }
            MyTrans.Commit();
        }
        catch
        {
            MyTrans.Rollback("Tran");
            res = -1;
        }
        Close();
        return res;
    }

    /// <summary>
    /// 删除资讯
    /// </summary>
    /// <param name="uid"></param>
    /// <param name="name"></param>
    /// <param name="ip"></param>
    /// <param name="ad_no"></param>
    /// <returns></returns>
    public int DeleteNews(string uid, string name, string ip, string nw_no)
    {
        int res = 0;
        Open();
        SqlCommand MyCommand = MyConnection.CreateCommand();
        SqlTransaction MyTrans = MyConnection.BeginTransaction("Tran");
        MyCommand.Connection = MyConnection;
        MyCommand.Transaction = MyTrans;
        try
        {
            string[] id = nw_no.Split(',');
            for (int i = 0; i < id.Length; i++)
            {
                MyCommand.CommandText = " select * from news where nw_no=@nw_no ";
                MyCommand.Parameters.Add("@nw_no", SqlDbType.BigInt).Value = id[i];
                DataTable dt = new DataTable();
                SqlDataAdapter da = new SqlDataAdapter(MyCommand);
                da.Fill(dt);
                if (dt != null && dt.Rows.Count > 0)
                {
                    string memo = "资讯：" + dt.Rows[0]["nw_title"].ToString();
                    MyCommand.CommandText = "delete from news where nw_no=@nw_no ";
                    res = MyCommand.ExecuteNonQuery();
                    if (res > 0)
                        WriteLog(uid, 3, ip, "用户【" + name + "】，在资讯管理功能中进行了数据删除操作，删除记录为【" + memo + "】。", MyCommand);
                }
                MyCommand.Parameters.Clear();
            }
            MyTrans.Commit();
            res = 1;
        }
        catch (Exception ex)
        {
            MyTrans.Rollback("Tran");
            res = -1;
        }
        Close();
        return res;
    }

    public int LockNews(string uid, string name, string ip, string nw_no, string nw_hide)
    {
        int res = 0;
        Open();
        SqlCommand MyCommand = MyConnection.CreateCommand();
        SqlTransaction MyTrans = MyConnection.BeginTransaction("Tran");
        MyCommand.Connection = MyConnection;
        MyCommand.Transaction = MyTrans;
        try
        {
            string[] id = nw_no.Split(',');
            for (int i = 0; i < id.Length; i++)
            {
                MyCommand.CommandText = " select * from news where nw_no=@nw_no ";
                MyCommand.Parameters.Add("@nw_no", SqlDbType.BigInt).Value = id[i];
                DataTable dt = new DataTable();
                SqlDataAdapter da = new SqlDataAdapter(MyCommand);
                da.Fill(dt);
                if (dt != null && dt.Rows.Count > 0)
                {
                    string memo = "";
                    if (!nw_hide.Equals(dt.Rows[0]["nw_hide"].ToString()))
                    {
                        string s1 = "隐藏";
                        if (ConfigurationManager.AppSettings["Open"].Equals(dt.Rows[0]["nw_hide"].ToString()))
                            s1 = "显示";
                        string s2 = "隐藏";
                        if (ConfigurationManager.AppSettings["Open"].Equals(nw_hide))
                            s2 = "显示";
                        memo = "资讯：" + dt.Rows[0]["nw_title"].ToString() + "，将状态从[" + s1 + "]改为[" + s2 + "]";
                    }
                    if (string.IsNullOrEmpty(memo))
                        memo = "资讯：" + dt.Rows[0]["nw_title"].ToString() + "，未修改任何字段";
                    MyCommand.CommandText = "update news set nw_hide=@nw_hide where nw_no=@nw_no ";
                    MyCommand.Parameters.Add("@nw_hide", SqlDbType.Int).Value = nw_hide;
                    res = MyCommand.ExecuteNonQuery();
                    if (res > 0)
                        WriteLog(uid, 2, ip, "用户【" + name + "】，在资讯管理功能中进行了数据修改操作，修改记录为【" + memo + "】。", MyCommand);
                }
                MyCommand.Parameters.Clear();
            }
            MyTrans.Commit();
            res = 1;
        }
        catch (Exception ex)
        {
            MyTrans.Rollback("Tran");
            res = -1;
        }
        Close();
        return res;
    }

    /// <summary>
    /// 
    /// </summary>
    /// <param name="uid"></param>
    /// <param name="name"></param>
    /// <param name="ip"></param>
    /// <param name="nw_no"></param>
    /// <param name="nw_orderid"></param>
    /// <returns></returns>
    public int TopNews(string uid, string name, string ip, string nw_no, string nw_orderid)
    {
        int res = 0;
        Open();
        SqlCommand MyCommand = MyConnection.CreateCommand();
        SqlTransaction MyTrans = MyConnection.BeginTransaction("Tran");
        MyCommand.Connection = MyConnection;
        MyCommand.Transaction = MyTrans;
        try
        {
            MyCommand.CommandText = " select nw_title from news where nw_no in (" + nw_no + ")";
            DataTable dt = new DataTable();
            SqlDataAdapter da = new SqlDataAdapter(MyCommand);
            da.Fill(dt);
            string top = "";
            if ("0".Equals(nw_orderid))
            {
                MyCommand.CommandText = "update news set nw_orderid=0 where nw_no in (" + nw_no + ")";
                top = "，取消置顶";
            }
            else
            {
                MyCommand.CommandText = "update news set nw_orderid=(select MAX(nw_orderid) + 1 from news) where nw_no in (" + nw_no + ")";
                top = "，置顶";
            }
            res = MyCommand.ExecuteNonQuery();

            if (res > 0)
            {
                string memo = "资讯：";
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    memo += dt.Rows[i]["nw_title"].ToString() + "、";
                }
                memo = memo.TrimEnd('、') + top;
                WriteLog(uid, 2, ip, "用户【" + name + "】，在资讯管理功能中进行了数据修改操作，修改记录为【将" + memo + "】。", MyCommand);
            }
            MyTrans.Commit();
            res = 1;
        }
        catch (Exception ex)
        {
            MyTrans.Rollback("Tran");
            res = -1;
        }
        Close();
        return res;
    }

    /// <summary>
    /// 
    /// </summary>
    /// <param name="uid"></param>
    /// <param name="name"></param>
    /// <param name="ip"></param>
    /// <param name="nw_no"></param>
    /// <param name="nw_red"></param>
    /// <returns></returns>
    public int RedNews(string uid, string name, string ip, string nw_no, string nw_red)
    {
        int res = 0;
        Open();
        SqlCommand MyCommand = MyConnection.CreateCommand();
        SqlTransaction MyTrans = MyConnection.BeginTransaction("Tran");
        MyCommand.Connection = MyConnection;
        MyCommand.Transaction = MyTrans;
        try
        {
            string[] id = nw_no.Split(',');
            for (int i = 0; i < id.Length; i++)
            {
                MyCommand.CommandText = " select * from news where nw_no=@nw_no ";
                MyCommand.Parameters.Add("@nw_no", SqlDbType.BigInt).Value = id[i];
                DataTable dt = new DataTable();
                SqlDataAdapter da = new SqlDataAdapter(MyCommand);
                da.Fill(dt);
                if (dt != null && dt.Rows.Count > 0)
                {
                    string memo = "";
                    if (!nw_red.Equals(dt.Rows[0]["nw_red"].ToString()))
                    {
                        string s = "描红";
                        if (ConfigurationManager.AppSettings["Open"].Equals(nw_red))
                            s = "取消描红";
                        memo = "资讯：" + dt.Rows[0]["nw_title"].ToString() + "，" + s;
                    }
                    if (string.IsNullOrEmpty(memo))
                        memo = "资讯：" + dt.Rows[0]["nw_title"].ToString() + "，未修改任何字段";
                    MyCommand.CommandText = "update news set nw_red=@nw_red where nw_no=@nw_no ";
                    MyCommand.Parameters.Add("@nw_red", SqlDbType.Int).Value = nw_red;
                    res = MyCommand.ExecuteNonQuery();
                    if (res > 0)
                        WriteLog(uid, 2, ip, "用户【" + name + "】，在资讯管理功能中进行了数据修改操作，修改记录为【" + memo + "】。", MyCommand);
                }
                MyCommand.Parameters.Clear();
            }
            MyTrans.Commit();
            res = 1;
        }
        catch (Exception ex)
        {
            MyTrans.Rollback("Tran");
            res = -1;
        }
        Close();
        return res;
    }

    /// <summary>
    /// 
    /// </summary>
    /// <param name="uid"></param>
    /// <param name="name"></param>
    /// <param name="ip"></param>
    /// <param name="nw_no"></param>
    /// <param name="nw_new"></param>
    /// <returns></returns>
    public int NewNews(string uid, string name, string ip, string nw_no, string nw_new)
    {
        int res = 0;
        Open();
        SqlCommand MyCommand = MyConnection.CreateCommand();
        SqlTransaction MyTrans = MyConnection.BeginTransaction("Tran");
        MyCommand.Connection = MyConnection;
        MyCommand.Transaction = MyTrans;
        try
        {
            string[] id = nw_no.Split(',');
            for (int i = 0; i < id.Length; i++)
            {
                MyCommand.CommandText = " select * from news where nw_no=@nw_no ";
                MyCommand.Parameters.Add("@nw_no", SqlDbType.BigInt).Value = id[i];
                DataTable dt = new DataTable();
                SqlDataAdapter da = new SqlDataAdapter(MyCommand);
                da.Fill(dt);
                if (dt != null && dt.Rows.Count > 0)
                {
                    string memo = "";
                    if (!nw_new.Equals(dt.Rows[0]["nw_new"].ToString()))
                    {
                        string s = "设置最新";
                        if (ConfigurationManager.AppSettings["Open"].Equals(nw_new))
                            s = "取消最新";
                        memo = "资讯：" + dt.Rows[0]["nw_title"].ToString() + "，" + s;
                    }
                    if (string.IsNullOrEmpty(memo))
                        memo = "资讯：" + dt.Rows[0]["nw_title"].ToString() + "，未修改任何字段";
                    MyCommand.CommandText = "update news set nw_new=@nw_new where nw_no=@nw_no ";
                    MyCommand.Parameters.Add("@nw_new", SqlDbType.Int).Value = nw_new;
                    res = MyCommand.ExecuteNonQuery();
                    if (res > 0)
                        WriteLog(uid, 2, ip, "用户【" + name + "】，在资讯管理功能中进行了数据修改操作，修改记录为【" + memo + "】。", MyCommand);
                }
                MyCommand.Parameters.Clear();
            }
            MyTrans.Commit();
            res = 1;
        }
        catch (Exception ex)
        {
            MyTrans.Rollback("Tran");
            res = -1;
        }
        Close();
        return res;
    }

    public int RefreshNews(string uid, string name, string ip, string nw_no, string state)
    {
        int res = 0;
        Open();
        SqlCommand MyCommand = MyConnection.CreateCommand();
        SqlTransaction MyTrans = MyConnection.BeginTransaction("Tran");
        MyCommand.Connection = MyConnection;
        MyCommand.Transaction = MyTrans;
        try
        {
            string[] id = nw_no.Split(',');
            for (int i = 0; i < id.Length; i++)
            {
                MyCommand.CommandText = " select * from news where nw_no=@nw_no ";
                MyCommand.Parameters.Add("@nw_no", SqlDbType.BigInt).Value = id[i];
                DataTable dt = new DataTable();
                SqlDataAdapter da = new SqlDataAdapter(MyCommand);
                da.Fill(dt);
                if (dt != null && dt.Rows.Count > 0)
                {
                    string memo = "";
                    string s = "";
                    if ("1".Equals(state))
                    {
                        s = "刷新";
                        MyCommand.CommandText = "update news set nw_modifytime=getdate() where nw_no=@nw_no ";
                    }
                    else
                    {
                        s = "取消刷新";
                        MyCommand.CommandText = "update news set nw_modifytime=nw_inserttime where nw_no=@nw_no ";
                    }
                    memo = "资讯：" + dt.Rows[0]["nw_title"].ToString() + "，" + s;
                    res = MyCommand.ExecuteNonQuery();
                    if (res > 0)
                        WriteLog(uid, 2, ip, "用户【" + name + "】，在资讯管理功能中进行了数据修改操作，修改记录为【" + memo + "】。", MyCommand);
                }
                MyCommand.Parameters.Clear();
            }
            MyTrans.Commit();
            res = 1;
        }
        catch (Exception ex)
        {
            MyTrans.Rollback("Tran");
            res = -1;
        }
        Close();
        return res;
    }

    /// <summary>
    /// 
    /// </summary>
    /// <param name="jt_state"></param>
    /// <returns></returns>
    public DataTable GetJobType(int jt_state)
    {
        Open();
        SqlCommand MyCommand = new SqlCommand();
        MyCommand.Connection = MyConnection;

        MyCommand.CommandText = "select * from jobtype where jt_state=@jt_state ";
        MyCommand.Parameters.Add("@jt_state", SqlDbType.Int).Value = jt_state;
        DataTable data = new DataTable();
        SqlDataAdapter adapter = new SqlDataAdapter(MyCommand);
        adapter.Fill(data);
        Close();
        return (data);
    }

    /// <summary>
    /// 
    /// </summary>
    /// <param name="type"></param>
    /// <param name="sdate"></param>
    /// <param name="edate"></param>
    /// <returns></returns>
    public ArrayList SJob(string type, string sdate, string edate)
    {
        Open();
        SqlCommand MyCommand = new SqlCommand();
        MyCommand.Connection = MyConnection;

        MyCommand.Parameters.Add("@sdate", SqlDbType.DateTime).Value = DateTime.Parse(sdate);
        MyCommand.Parameters.Add("@edate", SqlDbType.DateTime).Value = DateTime.Parse(edate);
        if (!string.IsNullOrEmpty(type) && !"0".Equals(type))
        {
            MyCommand.CommandText = "select jt_id,jt_name as job,count(re_no) as total from recruit left join jobtype on jt_id=re_jobtype1 where (re_inserttime between @sdate and @edate) and (jt_pid=@type or jt_id=@type) group by jt_id,jt_name order by jt_id ";
            MyCommand.Parameters.Add("@type", SqlDbType.Int).Value = type;
        }
        else
            MyCommand.CommandText = "select jt_pid,jt_name as job,count(re_no) as total from recruit left join jobtype on jt_id=re_jobtype1 where (re_inserttime between @sdate and @edate) and jt_pid<>0 group by jt_pid,jt_name ";

        DataTable data = new DataTable();
        SqlDataAdapter adapter = new SqlDataAdapter(MyCommand);
        adapter.Fill(data);
        Close();
        ArrayList da = DataTable2ArrayList(data);
        return da;
    }

    public ArrayList GetHtmlList()
    {
        Open();
        SqlCommand MyCommand = new SqlCommand();
        MyCommand.Connection = MyConnection;

        MyCommand.CommandText = " select ad_kind,ad_count3=(select COUNT(*) from advertisement where ad_hide=1 and ad_type=ad_kind),"
            + "ad_count2=(select COUNT(*) from advertisement where ad_hide=0 and DATEADD(DAY,ad_effecttime,ad_inserttime)<=GETDATE() and ad_type=ad_kind),"
            + "ad_count1=(select COUNT(*) from advertisement where ad_hide=0 and DATEADD(DAY,ad_effecttime,ad_inserttime)>GETDATE() and ad_type=ad_kind)"
            + " from (select ad_kind=ad_type,ad_sl=COUNT(*) from advertisement where ad_type in (1,2,3,4,5,6,7,8,9) group by ad_type) as  t1";

        DataTable data = new DataTable();
        SqlDataAdapter adapter = new SqlDataAdapter(MyCommand);
        adapter.Fill(data);
        Close();
        ArrayList da = DataTable2ArrayList(data);
        return da;
    }

    public DataTable GetAdList(int ad_type)
    {
        Open();
        SqlCommand MyCommand = new SqlCommand();
        MyCommand.Connection = MyConnection;
        MyCommand.CommandText = " select * from advertisement where ad_hide=0 and ad_type=@ad_type and DATEADD(DAY,ad_effecttime,ad_inserttime)>GETDATE() order by ad_orderid desc,ad_inserttime desc";
        MyCommand.Parameters.Add("@ad_type", SqlDbType.Int).Value = ad_type;
        DataTable data = new DataTable();
        SqlDataAdapter adapter = new SqlDataAdapter(MyCommand);
        adapter.Fill(data);
        Close();
        return data;
    }

    public DataTable GetAdList2(int ad_type)
    {
        Open();
        SqlCommand MyCommand = new SqlCommand();
        MyCommand.Connection = MyConnection;
        if ("0".Equals(ConfigurationManager.AppSettings["AdCount"]))
            MyCommand.CommandText = " select * from advertisement where ad_hide=0 and ad_type=@ad_type and DATEADD(DAY,ad_effecttime,ad_inserttime)>GETDATE() order by ad_inserttime desc";
        else
            MyCommand.CommandText = " select top " + ConfigurationManager.AppSettings["AdCount"] + " * from advertisement where ad_hide=0 and ad_type=@ad_type and DATEADD(DAY,ad_effecttime,ad_inserttime)>GETDATE() order by ad_inserttime desc";
        MyCommand.Parameters.Add("@ad_type", SqlDbType.Int).Value = ad_type;
        DataTable data = new DataTable();
        SqlDataAdapter adapter = new SqlDataAdapter(MyCommand);
        adapter.Fill(data);
        Close();
        return data;
    }

    public DataTable GetAdList3(int ad_type)
    {
        Open();
        SqlCommand MyCommand = new SqlCommand();
        MyCommand.Connection = MyConnection;
        MyCommand.CommandText = " select top 48 * from advertisement where ad_hide=0 and ad_type=@ad_type and DATEADD(DAY,ad_effecttime,ad_inserttime)<=GETDATE() ";
        MyCommand.Parameters.Add("@ad_type", SqlDbType.Int).Value = ad_type;
        DataTable data = new DataTable();
        SqlDataAdapter adapter = new SqlDataAdapter(MyCommand);
        adapter.Fill(data);
        Close();
        return data;
    }

    public DataTable GetNewsXinList()
    {
        Open();
        SqlCommand MyCommand = new SqlCommand();
        MyCommand.Connection = MyConnection;
        MyCommand.CommandText = " select top 8 * from news where nw_hide=0 and nw_type=14 order by nw_orderid desc,nw_modifytime desc ";
        DataTable data = new DataTable();
        SqlDataAdapter adapter = new SqlDataAdapter(MyCommand);
        adapter.Fill(data);
        Close();
        return data;
    }

    public DataTable GetNewsList(int nw_type)
    {
        Open();
        SqlCommand MyCommand = new SqlCommand();
        MyCommand.Connection = MyConnection;
        MyCommand.CommandText = " select top 8 *,datediff(day,nw_modifytime,getdate()) as dtime from news where nw_hide=0 and nw_type=@nw_type order by nw_modifytime desc ";
        MyCommand.Parameters.Add("@nw_type", SqlDbType.Int).Value = nw_type;
        DataTable data = new DataTable();
        SqlDataAdapter adapter = new SqlDataAdapter(MyCommand);
        adapter.Fill(data);
        Close();
        return data;
    }

    public DataTable GetJobfairList(int jf_type)
    {
        Open();
        SqlCommand MyCommand = new SqlCommand();
        MyCommand.Connection = MyConnection;
        MyCommand.CommandText = " select top 7 * from jobfair where jf_hide=0 and jf_type=@jf_type order by jf_modifytime desc";
        MyCommand.Parameters.Add("@jf_type", SqlDbType.Int).Value = jf_type;
        DataTable data = new DataTable();
        SqlDataAdapter adapter = new SqlDataAdapter(MyCommand);
        adapter.Fill(data);
        Close();
        return data;
    }

    public DataTable GetFriendLink(int fl_type)
    {
        Open();
        SqlCommand MyCommand = new SqlCommand();
        MyCommand.Connection = MyConnection;

        MyCommand.CommandText = "select * from friendlink where fl_hide=0 and fl_type=@fl_type order by fl_orderid desc";
        MyCommand.Parameters.Add("@fl_type", SqlDbType.Int).Value = fl_type;
        DataTable data = new DataTable();
        SqlDataAdapter adapter = new SqlDataAdapter(MyCommand);
        adapter.Fill(data);
        Close();
        return data;
    }

    public DataTable GetFriendLink(int fl_type, int fl_area)
    {
        Open();
        SqlCommand MyCommand = new SqlCommand();
        MyCommand.Connection = MyConnection;

        MyCommand.CommandText = "select * from friendlink where fl_hide=0 and fl_type=@fl_type and fl_area=@fl_area order by fl_orderid desc";
        MyCommand.Parameters.Add("@fl_type", SqlDbType.Int).Value = fl_type;
        MyCommand.Parameters.Add("@fl_area", SqlDbType.Int).Value = fl_area;
        DataTable data = new DataTable();
        SqlDataAdapter adapter = new SqlDataAdapter(MyCommand);
        adapter.Fill(data);
        Close();
        return data;
    }

    public Int64 GetCompanyCount()
    {
        Int64 ret = 0;
        Open();
        SqlCommand MyCommand = new SqlCommand();
        MyCommand.Connection = MyConnection;
        MyCommand.CommandText = "select count(1) from companyuser where cu_state=0 ";
        object o = MyCommand.ExecuteScalar();
        if (o != null && o.ToString() != "")
            ret = Int64.Parse(o.ToString());
        return ret;
    }

    public Int64 GetRecruitCount()
    {
        Int64 ret = 0;
        Open();
        SqlCommand MyCommand = new SqlCommand();
        MyCommand.Connection = MyConnection;
        MyCommand.CommandText = "select count(1) from recruit where re_state=0 ";
        object o = MyCommand.ExecuteScalar();
        if (o != null && o.ToString() != "")
            ret = Int64.Parse(o.ToString());
        return ret;
    }

    public Int64 GetPersonCount()
    {
        Int64 ret = 0;
        Open();
        SqlCommand MyCommand = new SqlCommand();
        MyCommand.Connection = MyConnection;
        MyCommand.CommandText = "select count(1) from personinfor where pi_state=0 ";
        object o = MyCommand.ExecuteScalar();
        if (o != null && o.ToString() != "")
            ret = Int64.Parse(o.ToString());
        return ret;
    }

    public Int64 GetAdCount()
    {
        Int64 ret = 0;
        Open();
        SqlCommand MyCommand = new SqlCommand();
        MyCommand.Connection = MyConnection;
        MyCommand.CommandText = "select count(1) from advertisement where DATEADD(DAY,ad_effecttime,ad_inserttime)<getdate() ";
        object o = MyCommand.ExecuteScalar();
        if (o != null && o.ToString() != "")
            ret = Int64.Parse(o.ToString());
        return ret;
    }

    public DataTable GetEnterCompanyList(string jf_no)
    {
        Open();
        SqlCommand MyCommand = new SqlCommand();
        MyCommand.Connection = MyConnection;
        MyCommand.CommandText = " select * from jobenter left join jobfair on je_jfno=jf_no where je_state=1 and je_jfno=@je_jfno ";
        MyCommand.Parameters.Add("@je_jfno", SqlDbType.BigInt).Value = jf_no;
        DataTable data = new DataTable();
        SqlDataAdapter adapter = new SqlDataAdapter(MyCommand);
        adapter.Fill(data);
        Close();
        return data;
    }

    public Hashtable GetStudent(string st_no)
    {
        Open();
        SqlCommand MyCommand = new SqlCommand();
        MyCommand.Connection = MyConnection;

        MyCommand.CommandText = "select * from student where st_no=@st_no";
        MyCommand.Parameters.Add("@st_no", SqlDbType.BigInt).Value = st_no;
        DataTable data = new DataTable();
        SqlDataAdapter adapter = new SqlDataAdapter(MyCommand);
        adapter.Fill(data);
        Close();
        ArrayList da = DataTable2ArrayList(data);
        return da.Count > 0 ? (Hashtable)da[0] : null;
    }

    public int SaveStudent(Hashtable data)
    {
        int res;
        Open();
        SqlCommand MyCommand = MyConnection.CreateCommand();
        SqlTransaction MyTrans;
        MyTrans = MyConnection.BeginTransaction("Tran");
        MyCommand.Connection = MyConnection;
        MyCommand.Transaction = MyTrans;
        try
        {
            //MyCommand.Parameters.Add("@st_name", SqlDbType.NVarChar).Value = data["st_name"];
            //MyCommand.Parameters.Add("@st_sex", SqlDbType.Int).Value = data["st_sex"];
            //MyCommand.Parameters.Add("@st_nation", SqlDbType.NVarChar).Value = data["st_nation"];
            //MyCommand.Parameters.Add("@st_card", SqlDbType.NVarChar).Value = data["st_card"];
            //MyCommand.Parameters.Add("@st_school", SqlDbType.NVarChar).Value = data["st_school"];
            //MyCommand.Parameters.Add("@st_finishtime", SqlDbType.NVarChar).Value = data["st_finishtime"];
            //MyCommand.Parameters.Add("@st_edu", SqlDbType.Int).Value = data["st_edu"];
            //MyCommand.Parameters.Add("@st_profession", SqlDbType.NVarChar).Value = data["st_profession"];
            //MyCommand.Parameters.Add("@st_address", SqlDbType.NVarChar).Value = data["st_address"];
            //MyCommand.Parameters.Add("@st_email", SqlDbType.NVarChar).Value = data["st_email"];
            //MyCommand.Parameters.Add("@st_postcode", SqlDbType.NVarChar).Value = data["st_postcode"];
            //MyCommand.Parameters.Add("@st_mobile", SqlDbType.NVarChar).Value = data["st_mobile"];
            //MyCommand.Parameters.Add("@st_tel", SqlDbType.NVarChar).Value = data["st_tel"];
            //MyCommand.Parameters.Add("@st_hard", SqlDbType.Int).Value = data["st_hard"];
            //MyCommand.Parameters.Add("@st_will1", SqlDbType.Int).Value = data["st_will1"];
            //MyCommand.Parameters.Add("@st_will2", SqlDbType.NVarChar).Value = data["st_will2"];
            //MyCommand.Parameters.Add("@st_need", SqlDbType.NVarChar).Value = data["st_need"];
            MyCommand.Parameters.Add("@st_goto", SqlDbType.NVarChar).Value = data["st_goto"] == "" ? DBNull.Value : data["st_goto"];
            MyCommand.Parameters.Add("@st_gotocompany", SqlDbType.NVarChar).Value = data["st_gotocompany"] == "" ? DBNull.Value : data["st_gotocompany"];
            MyCommand.Parameters.Add("@st_gotowork", SqlDbType.NVarChar).Value = data["st_gotowork"] == "" ? DBNull.Value : data["st_gotowork"];
            MyCommand.Parameters.Add("@st_memo", SqlDbType.NText).Value = data["st_memo"] == "" ? DBNull.Value : data["st_memo"];

            if (string.IsNullOrEmpty(data["st_no"].ToString()))
            {
                MyCommand.CommandText = "insert into student(st_name,st_sex,st_nation,st_card,st_school,st_finishtime,st_education,st_profession,st_address,st_email,st_postcode,st_mobile,st_tel,st_hard,st_will1,st_will2,st_need,st_goto,st_inserttime,st_insertip,st_state)" +
                    " values(@st_name,@st_sex,@st_nation,@st_card,@st_school,@st_finishtime,@st_education,@st_profession,@st_address,@st_email,@st_postcode,@st_mobile,@st_tel,@st_hard,@st_will1,@st_will2,@st_need,@st_goto,getDate(),@st_insertip,0)";
                MyCommand.Parameters.Add("@st_insertip", SqlDbType.NVarChar).Value = data["ip"];
                res = MyCommand.ExecuteNonQuery();
                if (res > 0)
                    WriteLog(data["user"].ToString(), 1, data["ip"].ToString(), "用户【" + data["name"].ToString() + "】，在未就业毕业生审核功能中进行了数据新增操作，新增记录为【姓名：" + data["st_name"] + "，身份号码：" + data["st_card"] + "】。", MyCommand);
                else
                    res = -1;
            }
            else
            {
                MyCommand.CommandText = " select * from student where st_no=@st_no ";
                MyCommand.Parameters.Add("@st_no", SqlDbType.BigInt).Value = data["st_no"];
                DataTable dt = new DataTable();
                SqlDataAdapter da = new SqlDataAdapter(MyCommand);
                da.Fill(dt);
                if (dt != null && dt.Rows.Count > 0)
                {
                    string memo = "";
                    if (!data["st_goto"].ToString().Equals(dt.Rows[0]["st_goto"].ToString()))
                        memo = "未就业毕业生：" + dt.Rows[0]["st_name"].ToString() + "，将就业去向从[" + dt.Rows[0]["st_goto"].ToString() + "]改为[" + data["st_goto"].ToString() + "]";
                    if (!data["st_gotocompany"].ToString().Equals(dt.Rows[0]["st_gotocompany"].ToString()))
                    {
                        if (string.IsNullOrEmpty(memo))
                            memo = "未就业毕业生：" + dt.Rows[0]["st_name"].ToString() + "，将就业去向单位从[" + dt.Rows[0]["st_gotocompany"].ToString() + "]改为[" + data["st_gotocompany"].ToString() + "]";
                        else
                            memo += "；将就业去向单位从[" + dt.Rows[0]["st_gotocompany"].ToString() + "]改为[" + data["st_gotocompany"].ToString() + "]";
                    }
                    if (!data["st_gotowork"].ToString().Equals(dt.Rows[0]["st_gotowork"].ToString()))
                    {
                        if (string.IsNullOrEmpty(memo))
                            memo = "未就业毕业生：" + dt.Rows[0]["st_name"].ToString() + "，将就业去向岗位从[" + dt.Rows[0]["st_gotowork"].ToString() + "]改为[" + data["st_gotowork"].ToString() + "]";
                        else
                            memo += "；将就业去向岗位从[" + dt.Rows[0]["st_gotowork"].ToString() + "]改为[" + data["st_gotowork"].ToString() + "]";
                    }
                    if (!data["st_memo"].ToString().Equals(dt.Rows[0]["st_memo"].ToString()))
                    {
                        if (string.IsNullOrEmpty(memo))
                            memo = "未就业毕业生：" + dt.Rows[0]["st_name"].ToString() + "，将其他说明情况从[" + dt.Rows[0]["st_memo"].ToString() + "]改为[" + data["st_memo"].ToString() + "]";
                        else
                            memo += "；将其他说明情况从[" + dt.Rows[0]["st_memo"].ToString() + "]改为[" + data["st_memo"].ToString() + "]";
                    }
                    if (string.IsNullOrEmpty(memo))
                        memo = "未就业毕业生：" + dt.Rows[0]["st_name"].ToString() + "，未修改任何字段";
                    MyCommand.CommandText = " update student set st_goto=@st_goto,st_gotocompany=@st_gotocompany,st_gotowork=@st_gotowork,st_memo=@st_memo where st_no=@st_no ";
                    res = MyCommand.ExecuteNonQuery();
                    if (res > 0)
                        WriteLog(data["user"].ToString(), 2, data["ip"].ToString(), "用户【" + data["name"].ToString() + "】，在未就业毕业生审核功能中进行了数据修改操作，修改记录为【" + memo + "】。", MyCommand);
                }
                else
                    res = 0;
            }
            MyTrans.Commit();
        }
        catch
        {
            MyTrans.Rollback("Tran");
            res = -1;
        }
        Close();
        return res;
    }

    public int DeleteStudent(string uid, string name, string ip, string st_no)
    {
        int res = 0;
        Open();
        SqlCommand MyCommand = MyConnection.CreateCommand();
        SqlTransaction MyTrans = MyConnection.BeginTransaction("Tran");
        MyCommand.Connection = MyConnection;
        MyCommand.Transaction = MyTrans;
        try
        {
            string[] id = st_no.Split(',');
            for (int i = 0; i < id.Length; i++)
            {
                MyCommand.CommandText = " select * from student where st_no=@st_no ";
                MyCommand.Parameters.Add("@st_no", SqlDbType.BigInt).Value = id[i];
                DataTable dt = new DataTable();
                SqlDataAdapter da = new SqlDataAdapter(MyCommand);
                da.Fill(dt);
                if (dt != null && dt.Rows.Count > 0)
                {
                    string memo = "未就业毕业生：" + dt.Rows[0]["st_name"].ToString();
                    MyCommand.CommandText = "delete from student where st_no=@st_no ";
                    res = MyCommand.ExecuteNonQuery();
                    if (res > 0)
                        WriteLog(uid, 3, ip, "用户【" + name + "】，在未就业毕业生审核功能中进行了未就业毕业生删除操作，删除记录为【" + memo + "】。", MyCommand);
                }
                MyCommand.Parameters.Clear();
            }
            MyTrans.Commit();
            res = 1;
        }
        catch (Exception ex)
        {
            MyTrans.Rollback("Tran");
            res = -1;
        }
        Close();
        return res;
    }

    public int CheckStudent(string uid, string name, string ip, string st_no, string st_state)
    {
        int res = 0;
        Open();
        SqlCommand MyCommand = MyConnection.CreateCommand();
        SqlTransaction MyTrans = MyConnection.BeginTransaction("Tran");
        MyCommand.Connection = MyConnection;
        MyCommand.Transaction = MyTrans;
        try
        {
            string[] id = st_no.Split(',');
            for (int i = 0; i < id.Length; i++)
            {
                MyCommand.CommandText = " select * from student where st_no=@st_no ";
                MyCommand.Parameters.Add("@st_no", SqlDbType.BigInt).Value = id[i];
                DataTable dt = new DataTable();
                SqlDataAdapter da = new SqlDataAdapter(MyCommand);
                da.Fill(dt);
                if (dt != null && dt.Rows.Count > 0)
                {
                    string memo = "";
                    if (!st_state.Equals(dt.Rows[0]["st_state"].ToString()))
                    {
                        string s1 = "未审核";
                        if ("1".Equals(dt.Rows[0]["st_state"].ToString()))
                            s1 = "审核通过";
                        else if ("2".Equals(dt.Rows[0]["st_state"].ToString()))
                            s1 = "审核不通过";
                        string s2 = "未审核";
                        if ("1".Equals(st_state))
                            s2 = "审核通过";
                        else if ("2".Equals(st_state))
                            s1 = "审核不通过";
                        memo = "未就业毕业生：" + dt.Rows[0]["st_name"].ToString() + "，将状态从[" + s1 + "]改为[" + s2 + "]";
                    }
                    if (string.IsNullOrEmpty(memo))
                        memo = "未就业毕业生：" + dt.Rows[0]["st_name"].ToString() + "，未修改任何字段";
                    MyCommand.CommandText = "update student set st_state=@st_state where st_no=@st_no ";
                    MyCommand.Parameters.Add("@st_state", SqlDbType.Int).Value = st_state;
                    res = MyCommand.ExecuteNonQuery();
                    if (res > 0)
                        WriteLog(uid, 2, ip, "用户【" + name + "】，在未就业毕业生审核功能中进行了数据修改操作，修改记录为【" + memo + "】。", MyCommand);
                }
                MyCommand.Parameters.Clear();
            }
            MyTrans.Commit();
            res = 1;
        }
        catch (Exception ex)
        {
            MyTrans.Rollback("Tran");
            res = -1;
        }
        Close();
        return res;
    }

    public string GetUserName(string su_no)
    {
        string res = "";
        Open();
        try
        {
            SqlCommand MyCommand = new SqlCommand("select su_login from systemuser where su_no=@su_no", MyConnection);
            MyCommand.Parameters.Add("@su_no", SqlDbType.BigInt).Value = su_no;
            res = MyCommand.ExecuteScalar().ToString();
        }
        catch (Exception e)
        {

        }
        Close();
        return res;
    }

    public DataTable GetSJobList(string type1, string type2, string sdate, string edate)
    {

        Open();
        SqlCommand MyCommand = new SqlCommand();
        MyCommand.Connection = MyConnection;
        MyCommand.CommandText = " select cu_no,cu_name,cu_contact,cu_tel,cu_address,re_name,re_num,(select di_name from dictionary where di_type=3 and di_code=re_area) as area,(select di_name from dictionary where di_type=5 and di_code=re_sex) as sex,(select di_name from dictionary where di_type=6 and di_code=re_kind) as kind,(select di_name from dictionary where di_type=4 and di_code=re_edu) as edu,re_edu2,(select di_name from dictionary where di_type=7 and di_code=re_target) as target,(select jt_name from jobtype where jt_id=re_jobtype1) as jobtype1,(select jt_name from jobtype where jt_id=re_jobtype11) as jobtype11,(select jt_name from jobtype where jt_id=re_jobtype2) as jobtype2,(select jt_name from jobtype where jt_id=re_jobtype22) as jobtype22,re_age,re_pay1,re_pay2,re_hits,re_resumenum,re_inserttime from recruit left join companyuser on re_cuno=cu_no where re_need<>1 and re_state=1 ";
        if (!string.IsNullOrEmpty(type1) && !"0".Equals(type1))
            MyCommand.CommandText += " and (re_jobtype1=" + type1 + " or re_jobtype2=" + type1 + ")";
        if (!string.IsNullOrEmpty(type2) && !"0".Equals(type2))
            MyCommand.CommandText += " and (re_jobtype11=" + type2 + " or re_jobtype22=" + type2 + ")";
        if (!string.IsNullOrEmpty(sdate))
            MyCommand.CommandText += " and re_inserttime>='" + sdate + "'";
        if (!string.IsNullOrEmpty(edate))
            MyCommand.CommandText += " and re_inserttime<='" + edate + "'";
        MyCommand.CommandText += " order by re_cuno desc ";
        DataTable data = new DataTable();
        SqlDataAdapter adapter = new SqlDataAdapter(MyCommand);
        adapter.Fill(data);
        Close();
        return data;
    }

    public DataTable GetSJobByTypeList(string type, string sdate, string edate)
    {
        Open();
        SqlCommand MyCommand = new SqlCommand();
        MyCommand.Connection = MyConnection;
        string table = "";
        string where = "";
        if (!string.IsNullOrEmpty(type) && !"0".Equals(type))
        {
            table = " recruit inner join jobtype on jt_id=re_jobtype11 ";
            where = " re_state=1 and re_jobtype1='" + type + "'";
        }
        else
        {
            table = " recruit inner join jobtype on jt_id=re_jobtype1 ";
            where = " re_state=1 and jt_pid='0'";
        }
        if (!string.IsNullOrEmpty(sdate))
            where += " and re_inserttime>='" + sdate + "'";
        if (!string.IsNullOrEmpty(edate))
            where += " and re_inserttime<='" + edate + "'";
        MyCommand.CommandText = " select jt_id,jt_name,count(re_no) as re_count,(cast((cast(count(re_no) as float)*100/(select case when count(re_no)=0 then 1 else count(re_no) end from " + table + " where " + where + ")) as numeric(5,2))) as re_percent from " + table + " where " + where;
        MyCommand.CommandText += " group by jt_id,jt_name order by re_count desc ";
        DataTable data = new DataTable();
        SqlDataAdapter adapter = new SqlDataAdapter(MyCommand);
        adapter.Fill(data);
        Close();
        return data;
    }

    public DataTable GetSJobByEduList(string sdate, string edate)
    {
        Open();
        SqlCommand MyCommand = new SqlCommand();
        MyCommand.Connection = MyConnection;
        string where = " re_state=1 ";
        if (!string.IsNullOrEmpty(sdate))
            where += " and re_inserttime>='" + sdate + "'";
        if (!string.IsNullOrEmpty(edate))
            where += " and re_inserttime<='" + edate + "'";
        MyCommand.CommandText = " select di_code,di_name,count(re_no) as re_count,(cast((cast(count(re_no) as float)*100/(select case when count(re_no)=0 then 1 else count(re_no) end from recruit inner join dictionary on di_code=re_edu and di_type=4 where " + where + ")) as numeric(5,2))) as re_percent from recruit inner join dictionary on di_code=re_edu and di_type=4 where " + where;
        MyCommand.CommandText += " group by di_code,di_name order by re_count desc ";
        DataTable data = new DataTable();
        SqlDataAdapter adapter = new SqlDataAdapter(MyCommand);
        adapter.Fill(data);
        Close();
        return data;
    }

    public DataTable GetSJobList2(string type1, string type2, string sdate, string edate)
    {
        Open();
        SqlCommand MyCommand = new SqlCommand();
        MyCommand.Connection = MyConnection;
        MyCommand.CommandText = " select cu_name,re_name,re_num,(select di_name from dictionary where di_type=3 and di_code=re_area) as area,(select di_name from dictionary where di_type=5 and di_code=re_sex) as sex,(select di_name from dictionary where di_type=6 and di_code=re_kind) as kind,(select di_name from dictionary where di_type=4 and di_code=re_edu) as edu,re_edu2,(select di_name from dictionary where di_type=7 and di_code=re_target) as target,(select jt_name from jobtype where jt_id=re_jobtype1) as jobtype1,(select jt_name from jobtype where jt_id=re_jobtype11) as jobtype11,(select jt_name from jobtype where jt_id=re_jobtype2) as jobtype2,(select jt_name from jobtype where jt_id=re_jobtype22) as jobtype22,re_age,re_pay1,re_pay2,re_hits,re_resumenum,re_inserttime from recruit left join companyuser on re_cuno=cu_no where re_need<>1 and re_state=1 ";
        if (!string.IsNullOrEmpty(type1) && !"0".Equals(type1))
            MyCommand.CommandText += " and (re_jobtype1=" + type1 + " or re_jobtype2=" + type1 + ")";
        if (!string.IsNullOrEmpty(type2) && !"0".Equals(type2))
            MyCommand.CommandText += " and (re_jobtype11=" + type2 + " or re_jobtype22=" + type2 + ")";
        if (!string.IsNullOrEmpty(sdate))
            MyCommand.CommandText += " and re_inserttime>='" + sdate + "'";
        if (!string.IsNullOrEmpty(edate))
            MyCommand.CommandText += " and re_inserttime<='" + edate + "'";
        MyCommand.CommandText += " order by re_cuno desc ";
        DataTable data = new DataTable();
        SqlDataAdapter adapter = new SqlDataAdapter(MyCommand);
        adapter.Fill(data);
        Close();
        return data;
    }

    public DataTable GetSPersonList(string type1, string type2, string sdate, string edate)
    {
        Open();
        SqlCommand MyCommand = new SqlCommand();
        MyCommand.Connection = MyConnection;
        MyCommand.CommandText = " select *,(select di_name from dictionary where di_type=3 and di_code=pi_workarea) as area,(select di_name from dictionary where di_type=5 and di_code=pi_sex) as sex,(select ma_name from major where ma_id=pi_spcode) as spcode,(select di_name from dictionary where di_type=4 and di_code=pi_edu) as edu,(select di_name from dictionary where di_type=6 and di_code=pi_jobtype) as kind,(select jt_name from jobtype where jt_id=pi_yx1) as yx1,(select jt_name from jobtype where jt_id=pi_yx11) as yx11,(select jt_name from jobtype where jt_id=pi_yx2) as yx2,(select jt_name from jobtype where jt_id=pi_yx22) as yx22 from personinfor where pi_high<>1 and pi_state=1 ";
        if (!string.IsNullOrEmpty(type1) && !"0".Equals(type1))
            MyCommand.CommandText += " and (pi_yx1=" + type1 + " or pi_yx2=" + type1 + ")";
        if (!string.IsNullOrEmpty(type2) && !"0".Equals(type2))
            MyCommand.CommandText += " and (pi_yx11=" + type2 + " or pi_yx22=" + type2 + ")";
        if (!string.IsNullOrEmpty(sdate))
            MyCommand.CommandText += " and pi_lastchgtime>='" + sdate + "'";
        if (!string.IsNullOrEmpty(edate))
            MyCommand.CommandText += " and pi_lastchgtime<='" + edate + "'";
        MyCommand.CommandText += " order by pi_no desc ";
        DataTable data = new DataTable();
        SqlDataAdapter adapter = new SqlDataAdapter(MyCommand);
        adapter.Fill(data);
        Close();
        return data;
    }

    public DataTable GetSPersonByMajorList(string type, string sdate, string edate)
    {
        Open();
        SqlCommand MyCommand = new SqlCommand();
        MyCommand.Connection = MyConnection;
        string where = " where pi_state=1 ";
        string select = "";
        string groupby = "";
        if (!string.IsNullOrEmpty(type) && !"0".Equals(type))
        {
            where += " and ma_id1='" + type + "'";
            select = " select ma_id2 as ma_id,ma_name2 as ma_name,count(pi_no) as pi_count ";
            groupby = "group by ma_id2,ma_name2";
        }
        else
        {
            select = " select ma_id1 as ma_id,ma_name1 as ma_name,count(pi_no) as pi_count ";
            groupby = "group by ma_id1,ma_name1";
        }
        if (!string.IsNullOrEmpty(sdate))
            where += " and pi_lastchgtime>='" + sdate + "'";
        if (!string.IsNullOrEmpty(edate))
            where += " and pi_lastchgtime<='" + edate + "'";
        select += ",(cast((cast(count(pi_no) as float)*100/(select case when count(pi_no)=0 then 1 else count(pi_no) end from personinfor inner join View_major on ma_id2=pi_spcode " + where + ")) as numeric(5,2))) as pi_percent ";
        MyCommand.CommandText = select + " from personinfor inner join View_major on ma_id2=pi_spcode " + where + groupby + " order by pi_count desc ";

        DataTable data = new DataTable();
        SqlDataAdapter adapter = new SqlDataAdapter(MyCommand);
        adapter.Fill(data);
        Close();
        return data;
    }

    public DataTable GetSPersonByYXList(string type, string sdate, string edate)
    {
        Open();
        SqlCommand MyCommand = new SqlCommand();
        MyCommand.Connection = MyConnection;
        string table = "";
        string where = "";
        if (!string.IsNullOrEmpty(type) && !"0".Equals(type))
        {
            table = " from personinfor inner join jobtype on jt_id=pi_yx11 ";
            where = " where pi_state=1 and pi_yx1='" + type + "'";
        }
        else
        {
            table = " from personinfor inner join jobtype on jt_id=pi_yx1 ";
            where = " where pi_state=1 and jt_pid='0'";
        }
        if (!string.IsNullOrEmpty(sdate))
            where += " and pi_lastchgtime>='" + sdate + "'";
        if (!string.IsNullOrEmpty(edate))
            where += " and pi_lastchgtime<='" + edate + "'";
        MyCommand.CommandText = " select jt_id,jt_name,count(pi_no) as pi_count,(cast((cast(count(pi_no) as float)*100/(select case when count(pi_no)=0 then 1 else count(pi_no) end " + table + where + ")) as numeric(5,2))) as pi_percent " + table + where;
        MyCommand.CommandText += " group by jt_id,jt_name order by pi_count desc ";
        DataTable data = new DataTable();
        SqlDataAdapter adapter = new SqlDataAdapter(MyCommand);
        adapter.Fill(data);
        Close();
        return data;
    }

    public DataTable GetSPersonByEduList(string sdate, string edate)
    {
        Open();
        SqlCommand MyCommand = new SqlCommand();
        MyCommand.Connection = MyConnection;
        string where = " where pi_state=1 ";
        if (!string.IsNullOrEmpty(sdate))
            where += " and pi_lastchgtime>='" + sdate + "'";
        if (!string.IsNullOrEmpty(edate))
            where += " and pi_lastchgtime<='" + edate + "'";
        MyCommand.CommandText = " select di_code,di_name,count(pi_no) as pi_count,(cast((cast(count(pi_no) as float)*100/(select case when count(pi_no)=0 then 1 else count(pi_no) end from personinfor inner join dictionary on di_code=pi_edu and di_type=4 " + where + ")) as numeric(5,2))) as pi_percent from personinfor inner join dictionary on di_code=pi_edu and di_type=4 " + where;
        MyCommand.CommandText += " group by di_code,di_name order by pi_count desc ";
        DataTable data = new DataTable();
        SqlDataAdapter adapter = new SqlDataAdapter(MyCommand);
        adapter.Fill(data);
        Close();
        return data;
    }

    public DataTable GetSNeedList(string type1, string type2, string sdate, string edate)
    {
        Open();
        SqlCommand MyCommand = new SqlCommand();
        MyCommand.Connection = MyConnection;
        MyCommand.CommandText = " select cu_name,re_name,re_num,(select di_name from dictionary where di_type=3 and di_code=re_area) as area,(select di_name from dictionary where di_type=5 and di_code=re_sex) as sex,(select di_name from dictionary where di_type=6 and di_code=re_kind) as kind,(select di_name from dictionary where di_type=4 and di_code=re_edu) as edu,re_edu2,(select di_name from dictionary where di_type=7 and di_code=re_target) as target,(select jt_name from jobtype where jt_id=re_jobtype1) as jobtype1,(select jt_name from jobtype where jt_id=re_jobtype11) as jobtype11,(select jt_name from jobtype where jt_id=re_jobtype2) as jobtype2,(select jt_name from jobtype where jt_id=re_jobtype22) as jobtype22,re_age,re_pay1,re_pay2,re_hits,re_resumenum,re_inserttime from recruit left join companyuser on re_cuno=cu_no where re_need=1 and re_needstate=1 ";
        if (!string.IsNullOrEmpty(type1) && !"0".Equals(type1))
            MyCommand.CommandText += " and (re_jobtype1=" + type1 + " or re_jobtype2=" + type1 + ")";
        if (!string.IsNullOrEmpty(type2) && !"0".Equals(type2))
            MyCommand.CommandText += " and (re_jobtype11=" + type2 + " or re_jobtype22=" + type2 + ")";
        if (!string.IsNullOrEmpty(sdate))
            MyCommand.CommandText += " and re_inserttime>='" + sdate + "'";
        if (!string.IsNullOrEmpty(edate))
            MyCommand.CommandText += " and re_inserttime<='" + edate + "'";
        MyCommand.CommandText += " order by re_cuno desc ";
        DataTable data = new DataTable();
        SqlDataAdapter adapter = new SqlDataAdapter(MyCommand);
        adapter.Fill(data);
        Close();
        return data;
    }

    public DataTable GetSNeedByTypeList(string type, string sdate, string edate)
    {
        Open();
        SqlCommand MyCommand = new SqlCommand();
        MyCommand.Connection = MyConnection;
        string table = "";
        string where = "";
        if (!string.IsNullOrEmpty(type) && !"0".Equals(type))
        {
            table = " recruit left join jobtype on jt_id=re_jobtype11 ";
            where = " re_need=1 and re_needstate=1 and re_jobtype1='" + type + "'";
        }
        else
        {
            table = " recruit left join jobtype on jt_id=re_jobtype1 ";
            where = " re_need=1 and re_needstate=1  ";
        }
        if (!string.IsNullOrEmpty(sdate))
            where += " and re_inserttime>='" + sdate + "'";
        if (!string.IsNullOrEmpty(edate))
            where += " and re_inserttime<='" + edate + "'";
        MyCommand.CommandText = " select jt_id,jt_name,count(re_no) as re_count,(cast((cast(count(re_no) as float)*100/(select case when count(re_no)=0 then 1 else count(re_no) end from " + table + " where " + where + ")) as numeric(5,2))) as re_percent from " + table + " where " + where;
        MyCommand.CommandText += " group by jt_id,jt_name order by re_count desc ";
        DataTable data = new DataTable();
        SqlDataAdapter adapter = new SqlDataAdapter(MyCommand);
        adapter.Fill(data);
        Close();
        return data;
    }

    public DataTable GetSNeedByEduList(string sdate, string edate)
    {
        Open();
        SqlCommand MyCommand = new SqlCommand();
        MyCommand.Connection = MyConnection;
        string where = " re_need=1 and re_needstate=1 ";
        if (!string.IsNullOrEmpty(sdate))
            where += " and re_inserttime>='" + sdate + "'";
        if (!string.IsNullOrEmpty(edate))
            where += " and re_inserttime<='" + edate + "'";
        MyCommand.CommandText = " select di_code,di_name,count(re_no) as re_count,(cast((cast(count(re_no) as float)*100/(select case when count(re_no)=0 then 1 else count(re_no) end from recruit inner join dictionary on di_code=re_edu and di_type=4 where " + where + ")) as numeric(5,2))) as re_percent from recruit inner join dictionary on di_code=re_edu and di_type=4 where " + where;
        MyCommand.CommandText += " group by di_code,di_name order by re_count desc ";
        DataTable data = new DataTable();
        SqlDataAdapter adapter = new SqlDataAdapter(MyCommand);
        adapter.Fill(data);
        Close();
        return data;
    }

    public DataTable GetSHighList(string type1, string type2, string sdate, string edate)
    {
        Open();
        SqlCommand MyCommand = new SqlCommand();
        MyCommand.Connection = MyConnection;
        MyCommand.CommandText = " select *,(select di_name from dictionary where di_type=3 and di_code=pi_workarea) as area,(select di_name from dictionary where di_type=5 and di_code=pi_sex) as sex,(select ma_name from major where ma_id=pi_spcode) as spcode,(select di_name from dictionary where di_type=4 and di_code=pi_edu) as edu,(select di_name from dictionary where di_type=6 and di_code=pi_jobtype) as kind,(select jt_name from jobtype where jt_id=pi_yx1) as yx1,(select jt_name from jobtype where jt_id=pi_yx11) as yx11,(select jt_name from jobtype where jt_id=pi_yx2) as yx2,(select jt_name from jobtype where jt_id=pi_yx22) as yx22 from personinfor where pi_high=1 and pi_highstate=1 ";
        if (!string.IsNullOrEmpty(type1) && !"0".Equals(type1))
            MyCommand.CommandText += " and (pi_yx1=" + type1 + " or pi_yx2=" + type1 + ")";
        if (!string.IsNullOrEmpty(type2) && !"0".Equals(type2))
            MyCommand.CommandText += " and (pi_yx11=" + type2 + " or pi_yx22=" + type2 + ")";
        if (!string.IsNullOrEmpty(sdate))
            MyCommand.CommandText += " and pi_lastchgtime>='" + sdate + "'";
        if (!string.IsNullOrEmpty(edate))
            MyCommand.CommandText += " and pi_lastchgtime<='" + edate + "'";
        MyCommand.CommandText += " order by pi_no desc ";
        DataTable data = new DataTable();
        SqlDataAdapter adapter = new SqlDataAdapter(MyCommand);
        adapter.Fill(data);
        Close();
        return data;
    }

    public DataTable GetSHighByMajorList(string type, string sdate, string edate)
    {
        Open();
        SqlCommand MyCommand = new SqlCommand();
        MyCommand.Connection = MyConnection;
        string where = " where pi_state=1 and (pi_edu in ('7','8','9') or pi_zhicheng in ('中级职称','高级职称')) ";
        string select = "";
        string groupby = "";
        if (!string.IsNullOrEmpty(type) && !"0".Equals(type))
        {
            where += " and ma_id1='" + type + "'";
            select = " select ma_id2 as ma_id,ma_name2 as ma_name,count(pi_no) as pi_count ";
            groupby = "group by ma_id2,ma_name2";
        }
        else
        {
            select = " select ma_id1 as ma_id,ma_name1 as ma_name,count(pi_no) as pi_count ";
            groupby = "group by ma_id1,ma_name1";
        }
        if (!string.IsNullOrEmpty(sdate))
            where += " and pi_lastchgtime>='" + sdate + "'";
        if (!string.IsNullOrEmpty(edate))
            where += " and pi_lastchgtime<='" + edate + "'";
        select += ",(cast((cast(count(pi_no) as float)*100/(select case when count(pi_no)=0 then 1 else count(pi_no) end from personinfor inner join View_major on ma_id2=pi_spcode " + where + ")) as numeric(5,2))) as pi_percent ";
        MyCommand.CommandText = select + " from personinfor inner join View_major on ma_id2=pi_spcode " + where + groupby + " order by pi_count desc ";

        DataTable data = new DataTable();
        SqlDataAdapter adapter = new SqlDataAdapter(MyCommand);
        adapter.Fill(data);
        Close();
        return data;
    }

    public DataTable GetSHighByYXList(string type, string sdate, string edate)
    {
        Open();
        SqlCommand MyCommand = new SqlCommand();
        MyCommand.Connection = MyConnection;
        string table = "";
        string where = "";
        if (!string.IsNullOrEmpty(type) && !"0".Equals(type))
        {
            table = " from personinfor inner join jobtype on jt_id=pi_yx11 ";
            where = " where pi_state=1 and (pi_edu in ('7','8','9') or pi_zhicheng in ('中级职称','高级职称')) and pi_yx1='" + type + "'";
        }
        else
        {
            table = " from personinfor inner join jobtype on jt_id=pi_yx1 ";
            where = " where pi_state=1 and (pi_edu in ('7','8','9') or pi_zhicheng in ('中级职称','高级职称')) and jt_pid='0'";
        }
        if (!string.IsNullOrEmpty(sdate))
            where += " and pi_lastchgtime>='" + sdate + "'";
        if (!string.IsNullOrEmpty(edate))
            where += " and pi_lastchgtime<='" + edate + "'";
        MyCommand.CommandText = " select jt_id,jt_name,count(pi_no) as pi_count,(cast((cast(count(pi_no) as float)*100/(select case when count(pi_no)=0 then 1 else count(pi_no) end " + table + where + ")) as numeric(5,2))) as pi_percent " + table + where;
        MyCommand.CommandText += " group by jt_id,jt_name order by pi_count desc ";
        DataTable data = new DataTable();
        SqlDataAdapter adapter = new SqlDataAdapter(MyCommand);
        adapter.Fill(data);
        Close();
        return data;
    }

    public DataTable GetSHighByEduList(string sdate, string edate)
    {
        Open();
        SqlCommand MyCommand = new SqlCommand();
        MyCommand.Connection = MyConnection;
        string where = " where pi_state=1 and (pi_edu in ('7','8','9') or pi_zhicheng in ('中级职称','高级职称')) ";
        if (!string.IsNullOrEmpty(sdate))
            where += " and pi_lastchgtime>='" + sdate + "'";
        if (!string.IsNullOrEmpty(edate))
            where += " and pi_lastchgtime<='" + edate + "'";
        MyCommand.CommandText = " select di_code,di_name,count(pi_no) as pi_count,(cast((cast(count(pi_no) as float)*100/(select case when count(pi_no)=0 then 1 else count(pi_no) end from personinfor inner join dictionary on di_code=pi_edu and di_type=4 " + where + ")) as numeric(5,2))) as pi_percent from personinfor inner join dictionary on di_code=pi_edu and di_type=4 " + where;
        MyCommand.CommandText += " group by di_code,di_name order by pi_count desc ";
        DataTable data = new DataTable();
        SqlDataAdapter adapter = new SqlDataAdapter(MyCommand);
        adapter.Fill(data);
        Close();
        return data;
    }

    public DataTable GetSStudentList(string edu, string hard, string will1, string will2, string need, string go, string sdate, string edate)
    {
        Open();
        SqlCommand MyCommand = new SqlCommand();
        MyCommand.Connection = MyConnection;
        MyCommand.CommandText = " select * from student where st_state=1 ";
        if (!string.IsNullOrEmpty(edu) && !"0".Equals(edu))
            MyCommand.CommandText += " and st_edu='" + edu + "'";
        if (!string.IsNullOrEmpty(hard) && !"-1".Equals(hard))
            MyCommand.CommandText += " and st_hard=" + hard;
        if (!string.IsNullOrEmpty(will1) && !"0".Equals(will1))
        {
            if ("其他地区".Equals(will1))
                MyCommand.CommandText += " and st_willarea not in ('不限','本市','本省') ";
            else
                MyCommand.CommandText += " and st_willarea='" + will1 + "'";
        }
        if (!string.IsNullOrEmpty(will2) && !"0".Equals(will2))
            MyCommand.CommandText += " and st_willkind='" + will2 + "'";
        if (!string.IsNullOrEmpty(need) && !"0".Equals(need))
            MyCommand.CommandText += " and st_need like '%," + need + ",%'";
        if (!string.IsNullOrEmpty(go) && !"0".Equals(go))
            MyCommand.CommandText += " and st_goto=" + go;
        if (!string.IsNullOrEmpty(sdate))
            MyCommand.CommandText += " and st_finishtime>='" + sdate + "'";
        if (!string.IsNullOrEmpty(edate))
            MyCommand.CommandText += " and st_finishtime<='" + edate + "'";
        MyCommand.CommandText += " order by st_no desc ";
        DataTable data = new DataTable();
        SqlDataAdapter adapter = new SqlDataAdapter(MyCommand);
        adapter.Fill(data);
        Close();
        return data;
    }

    public DataTable GetSCompanyByTradeList(string sdate, string edate)
    {
        Open();
        SqlCommand MyCommand = new SqlCommand();
        MyCommand.Connection = MyConnection;
        string where = " where cu_state=1 ";
        if (!string.IsNullOrEmpty(sdate))
            where += " and cu_apptime>='" + sdate + "'";
        if (!string.IsNullOrEmpty(edate))
            where += " and cu_apptime<='" + edate + "'";
        MyCommand.CommandText = " select di_code,di_name,count(cu_no) as cu_count,(cast((cast(count(cu_no) as float)*100/(select case when count(cu_no)=0 then 1 else count(cu_no) end from companyuser left join dictionary on di_code=cu_trade and di_type=1 " + where + ")) as numeric(5,2))) as cu_percent from companyuser left join dictionary on di_code=cu_trade and di_type=1 " + where;
        MyCommand.CommandText += " group by di_code,di_name order by cu_count desc ";
        DataTable data = new DataTable();
        SqlDataAdapter adapter = new SqlDataAdapter(MyCommand);
        adapter.Fill(data);
        Close();
        return data;
    }
    public DataTable GetSCompanyByTypeList(string sdate, string edate)
    {
        Open();
        SqlCommand MyCommand = new SqlCommand();
        MyCommand.Connection = MyConnection;
        string where = " where re_state=1 and re_jobtype1 in (select jt_id from jobtype)";
        if (!string.IsNullOrEmpty(sdate))
            where += " and re_inserttime>='" + sdate + "'";
        if (!string.IsNullOrEmpty(edate))
            where += " and re_inserttime<='" + edate + "'";
        MyCommand.CommandText = " select cu_name,cu_contact,cu_tel,re_name,re_num,"
        + "(select di_name from dictionary where di_code=re_kind and di_type=6) as kind,"
        + "(case re_pay1 when '1'  then    '1000~1500' when '2' then  '1500~2000'  when '3' then '2000~3000' when '4'  then '3000~5000' when '5'  then '5000~10000' when '6'   then '10000以上' else  '面议' end) as salary,"
        + "(select di_name from dictionary where di_code=re_sex and di_type=5) as sex,"
        + "(select di_name from dictionary where di_code=re_edu and di_type=4) as edu,"
        + "(select di_name from dictionary where di_code=re_area and di_type=3) as area,"
        + "ISNULL ( (select jt_name from jobtype where jt_id=re_jobtype11),(select jt_name from jobtype where jt_id=re_jobtype1))   as positionType,"
        + "re_inserttime,DATEADD(day,re_effecttime,re_delaytime) as deadline,re_memo"
        + " from recruit left join companyuser on re_cuno=cu_no " + where;
        DataTable data = new DataTable();
        SqlDataAdapter adapter = new SqlDataAdapter(MyCommand);
        adapter.Fill(data);
        Close();
        return data;
    }
    public DataTable GetVipCompany()
    {
        Open();
        SqlCommand comm = new SqlCommand("VipCompany", MyConnection);
        comm.CommandType = CommandType.StoredProcedure;
        SqlDataAdapter da = new SqlDataAdapter(comm);
        DataTable dt = new DataTable();
        da.Fill(dt);
        MyConnection.Close();
        return dt;
    }

    public DataTable GetNewCompany()
    {
        Open();
        SqlCommand comm = new SqlCommand("NewCompany", MyConnection);
        comm.CommandType = CommandType.StoredProcedure;
        SqlDataAdapter da = new SqlDataAdapter(comm);
        DataTable dt = new DataTable();
        da.Fill(dt);
        MyConnection.Close();
        return dt;
    }

    public DataTable GetTopJob()
    {
        Open();
        SqlCommand comm = new SqlCommand("TopJob", MyConnection);
        comm.CommandType = CommandType.StoredProcedure;
        SqlDataAdapter da = new SqlDataAdapter(comm);
        DataTable dt = new DataTable();
        da.Fill(dt);
        MyConnection.Close();
        return dt;
    }
    //高薪板块展示2015-6-12
    public DataTable GetWellPayJob()
    {
        Open();
        SqlCommand comm = new SqlCommand("WellPayJob", MyConnection);
        comm.CommandType = CommandType.StoredProcedure;
        SqlDataAdapter da = new SqlDataAdapter(comm);
        DataTable dt = new DataTable();
        da.Fill(dt);
        MyConnection.Close();
        return dt;
    }
    public void UpdateCreatTime(string uid, string name, string ip)
    {
        Open();
        SqlCommand MyCommand = new SqlCommand();
        MyCommand.Connection = MyConnection;
        try
        {
            MyCommand.CommandText = " update Html set ht_time=getdate() where ht_no=1 ";
            int res = MyCommand.ExecuteNonQuery();
            if (res > 0)
                WriteLog(uid, 2, ip, "用户【" + name + "】生成人才网首页", MyCommand);
        }
        catch (Exception e)
        {
        }
        Close();
    }

    public ArrayList GetPartyNewsList()
    {
        Open();
        SqlCommand MyCommand = new SqlCommand();
        MyCommand.Connection = MyConnection;

        MyCommand.CommandText = " select nw_type,COUNT(nw_no) as nw_count from news where nw_hide=0 and nw_type in (41,42,43,44,45,46,47) group by nw_type ";

        DataTable data = new DataTable();
        SqlDataAdapter adapter = new SqlDataAdapter(MyCommand);
        adapter.Fill(data);
        Close();
        ArrayList da = DataTable2ArrayList(data);
        return da;
    }

    public DataTable GetParty9List(int nw_type)
    {
        Open();
        SqlCommand MyCommand = new SqlCommand();
        MyCommand.Connection = MyConnection;
        MyCommand.CommandText = " select top 9 * from news where nw_hide=0 and nw_type=@nw_type order by nw_orderid desc,nw_no desc ";
        MyCommand.Parameters.Add("@nw_type", SqlDbType.Int).Value = nw_type;
        DataTable data = new DataTable();
        SqlDataAdapter adapter = new SqlDataAdapter(MyCommand);
        adapter.Fill(data);
        Close();
        return data;
    }

    public DataTable GetParty7List(int nw_type)
    {
        Open();
        SqlCommand MyCommand = new SqlCommand();
        MyCommand.Connection = MyConnection;
        MyCommand.CommandText = " select top 7 * from news where nw_hide=0 and nw_type=@nw_type order by nw_orderid desc,nw_no desc ";
        MyCommand.Parameters.Add("@nw_type", SqlDbType.Int).Value = nw_type;
        DataTable data = new DataTable();
        SqlDataAdapter adapter = new SqlDataAdapter(MyCommand);
        adapter.Fill(data);
        Close();
        return data;
    }

    public DataTable GetPartyPic4List(int nw_type)
    {
        Open();
        SqlCommand MyCommand = new SqlCommand();
        MyCommand.Connection = MyConnection;
        MyCommand.CommandText = " select top 4 * from news where nw_hide=0 and nw_type=@nw_type and nw_img is not null and nw_img<>'' order by nw_orderid desc,nw_no desc";
        MyCommand.Parameters.Add("@nw_type", SqlDbType.Int).Value = nw_type;
        DataTable data = new DataTable();
        SqlDataAdapter adapter = new SqlDataAdapter(MyCommand);
        adapter.Fill(data);
        Close();
        return data;
    }

    public ArrayList GetHRNewsList()
    {
        Open();
        SqlCommand MyCommand = new SqlCommand();
        MyCommand.Connection = MyConnection;

        MyCommand.CommandText = " select nw_type,COUNT(nw_no) as nw_count from news where nw_hide=0 and nw_type in (70,76,77,78) group by nw_type ";

        DataTable data = new DataTable();
        SqlDataAdapter adapter = new SqlDataAdapter(MyCommand);
        adapter.Fill(data);
        Close();
        ArrayList da = DataTable2ArrayList(data);
        return da;
    }

    public DataTable GetHR9List(int nw_type)
    {
        Open();
        SqlCommand MyCommand = new SqlCommand();
        MyCommand.Connection = MyConnection;
        MyCommand.CommandText = " select top 10 * from news where nw_hide=0 and nw_type=@nw_type order by nw_orderid desc,nw_no desc ";
        MyCommand.Parameters.Add("@nw_type", SqlDbType.Int).Value = nw_type;
        DataTable data = new DataTable();
        SqlDataAdapter adapter = new SqlDataAdapter(MyCommand);
        adapter.Fill(data);
        Close();
        return data;
    }

    public DataTable GetHR7List(int nw_type)
    {
        Open();
        SqlCommand MyCommand = new SqlCommand();
        MyCommand.Connection = MyConnection;
        MyCommand.CommandText = " select top 7 * from news where nw_hide=0 and nw_type=@nw_type order by nw_orderid desc,nw_no desc ";
        MyCommand.Parameters.Add("@nw_type", SqlDbType.Int).Value = nw_type;
        DataTable data = new DataTable();
        SqlDataAdapter adapter = new SqlDataAdapter(MyCommand);
        adapter.Fill(data);
        Close();
        return data;
    }

    public DataTable GetHRXHZLList(int nw_type)
    {
        Open();
        SqlCommand MyCommand = new SqlCommand();
        MyCommand.Connection = MyConnection;
        MyCommand.CommandText = " select top 1 * from news where nw_hide=0 and nw_type=@nw_type order by nw_orderid desc,nw_no desc ";
        MyCommand.Parameters.Add("@nw_type", SqlDbType.Int).Value = nw_type;
        DataTable data = new DataTable();
        SqlDataAdapter adapter = new SqlDataAdapter(MyCommand);
        adapter.Fill(data);
        Close();
        return data;
    }

    public DataTable GetHRPic4List(int nw_type)
    {
        Open();
        SqlCommand MyCommand = new SqlCommand();
        MyCommand.Connection = MyConnection;
        MyCommand.CommandText = " select top 4 * from news where nw_hide=0 and nw_type=@nw_type and nw_img is not null order by nw_orderid desc,nw_no desc ";
        MyCommand.Parameters.Add("@nw_type", SqlDbType.Int).Value = nw_type;
        DataTable data = new DataTable();
        SqlDataAdapter adapter = new SqlDataAdapter(MyCommand);
        adapter.Fill(data);
        Close();
        return data;
    }

    public ArrayList GetHighNewsList()
    {
        Open();
        SqlCommand MyCommand = new SqlCommand();
        MyCommand.Connection = MyConnection;

        MyCommand.CommandText = " select nw_type,COUNT(nw_no) as nw_count from news where nw_hide=0 and nw_type in (82,83,84,85) group by nw_type ";

        DataTable data = new DataTable();
        SqlDataAdapter adapter = new SqlDataAdapter(MyCommand);
        adapter.Fill(data);
        Close();
        ArrayList da = DataTable2ArrayList(data);
        return da;
    }

    public DataTable GetHighTpList(int nw_type)
    {
        Open();
        SqlCommand MyCommand = new SqlCommand();
        MyCommand.Connection = MyConnection;
        MyCommand.CommandText = " select top 4 * from news where nw_hide=0 and nw_type=@nw_type and nw_img is not null and len(nw_img)>0 order by nw_orderid desc,nw_no desc ";
        MyCommand.Parameters.Add("@nw_type", SqlDbType.Int).Value = nw_type;
        DataTable data = new DataTable();
        SqlDataAdapter adapter = new SqlDataAdapter(MyCommand);
        adapter.Fill(data);
        Close();
        return data;
    }

    public DataTable GetHigh10List(int nw_type)
    {
        Open();
        SqlCommand MyCommand = new SqlCommand();
        MyCommand.Connection = MyConnection;
        MyCommand.CommandText = " select top 10 * from news where nw_hide=0 and nw_type=@nw_type order by nw_orderid desc,nw_no desc ";
        MyCommand.Parameters.Add("@nw_type", SqlDbType.Int).Value = nw_type;
        DataTable data = new DataTable();
        SqlDataAdapter adapter = new SqlDataAdapter(MyCommand);
        adapter.Fill(data);
        Close();
        return data;
    }

    public DataTable GetHigh6List(int nw_type)
    {
        Open();
        SqlCommand MyCommand = new SqlCommand();
        MyCommand.Connection = MyConnection;
        MyCommand.CommandText = " select top 6 * from news where nw_hide=0 and nw_type=@nw_type order by nw_orderid desc,nw_no desc ";
        MyCommand.Parameters.Add("@nw_type", SqlDbType.Int).Value = nw_type;
        DataTable data = new DataTable();
        SqlDataAdapter adapter = new SqlDataAdapter(MyCommand);
        adapter.Fill(data);
        Close();
        return data;
    }

    public DataTable GetHighConsultList(int cs_asktype)
    {
        Open();
        SqlCommand MyCommand = new SqlCommand();
        MyCommand.Connection = MyConnection;
        MyCommand.CommandText = " select top 3 * from consult where cs_hide=0 and cs_asktype=@cs_asktype and cs_hftime is not null order by cs_no desc ";
        MyCommand.Parameters.Add("@cs_asktype", SqlDbType.Int).Value = cs_asktype;
        DataTable data = new DataTable();
        SqlDataAdapter adapter = new SqlDataAdapter(MyCommand);
        adapter.Fill(data);
        Close();
        return data;
    }

    public DataTable GetPictureNews(int count)
    {
        Open();
        SqlCommand MyCommand = new SqlCommand();
        MyCommand.Connection = MyConnection;

        MyCommand.CommandText = "select top 4 * from news where nw_hide=0 and nw_new=1 and nw_type in (11,12,13,14) and nw_img is not null and nw_img<>'' order by nw_modifytime desc";
        DataTable data = new DataTable();
        SqlDataAdapter adapter = new SqlDataAdapter(MyCommand);
        adapter.Fill(data);
        Close();
        return data;
    }

    /// <summary>
    /// 重置企业密码
    /// </summary>
    /// <param name="uid"></param>
    /// <param name="name"></param>
    /// <param name="ip"></param>
    /// <param name="cu_no"></param>
    /// <returns></returns>
    public int ResetPass(string uid, string name, string ip, string cu_no)
    {
        int res = 0;
        Open();
        SqlCommand MyCommand = MyConnection.CreateCommand();
        SqlTransaction MyTrans = MyConnection.BeginTransaction("Tran");
        MyCommand.Connection = MyConnection;
        MyCommand.Transaction = MyTrans;
        try
        {
            MyCommand.CommandText = " select * from companyuser where cu_no=@cu_no ";
            MyCommand.Parameters.Add("@cu_no", SqlDbType.BigInt).Value = cu_no;
            DataTable dt = new DataTable();
            SqlDataAdapter da = new SqlDataAdapter(MyCommand);
            da.Fill(dt);
            if (dt != null && dt.Rows.Count > 0)
            {
                string memo = "重置企业：" + dt.Rows[0]["cu_name"].ToString() + "密码。";
                MyCommand.CommandText = "update companyuser set cu_password=@cu_password where cu_no=@cu_no ";
                MyCommand.Parameters.Add("@cu_password", SqlDbType.NVarChar).Value = FormsAuthentication.HashPasswordForStoringInConfigFile("888888", "MD5").ToLower();
                res = MyCommand.ExecuteNonQuery();
                if (res > 0)
                    WriteLog(uid, 2, ip, "用户【" + name + "】，在招聘企业管理功能中进行了重置企业密码操作，操作记录为【" + memo + "】。", MyCommand);
            }
            else
                res = 0;
            MyTrans.Commit();
        }
        catch (Exception ex)
        {
            MyTrans.Rollback("Tran");
            res = -1;
        }
        Close();
        return res;
    }

    public int SaveArchives(string uid, string name, string ip, DataTable dt)
    {
        int res = 0;
        Open();
        SqlCommand MyCommand = MyConnection.CreateCommand();
        SqlTransaction MyTrans;
        MyTrans = MyConnection.BeginTransaction("Tran");
        MyCommand.Connection = MyConnection;
        MyCommand.Transaction = MyTrans;
        try
        {
            int count = 0;
            //if (dt.Rows.Count > 0)
            //{
            //    MyCommand.CommandText = "truncate table archives";
            //    MyCommand.ExecuteNonQuery();
            //}
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                string value = dt.Rows[i]["档案编号"].ToString() + dt.Rows[i]["姓名"].ToString() + dt.Rows[i]["身份证号"].ToString() + dt.Rows[i]["档案类型"].ToString() + dt.Rows[i]["性别"].ToString() + dt.Rows[i]["出生年月"].ToString() + dt.Rows[i]["是否转出"].ToString() + dt.Rows[i]["入库日期"].ToString() + dt.Rows[i]["毕业院校"].ToString();
                if (!string.IsNullOrEmpty(value))
                {
                    MyCommand.CommandText = "insert into archives (ar_id,ar_name,ar_type,ar_sex,ar_birth,ar_school,ar_state,ar_inserttime,ar_card) values (@ar_id,@ar_name,@ar_type,@ar_sex,@ar_birth,@ar_school,@ar_state,@ar_inserttime,@ar_card)";
                    MyCommand.Parameters.Add("@ar_id", SqlDbType.NVarChar).Value = dt.Rows[i]["档案编号"].ToString();
                    MyCommand.Parameters.Add("@ar_name", SqlDbType.NVarChar).Value = dt.Rows[i]["姓名"].ToString();
                    if ("毕业生".Equals(dt.Rows[i]["档案类型"].ToString()))
                        MyCommand.Parameters.Add("@ar_type", SqlDbType.Int).Value = 1;
                    else if ("社会人员".Equals(dt.Rows[i]["档案类型"].ToString()))
                        MyCommand.Parameters.Add("@ar_type", SqlDbType.Int).Value = 2;
                    else
                        MyCommand.Parameters.Add("@ar_type", SqlDbType.Int).Value = DBNull.Value;
                    MyCommand.Parameters.Add("@ar_sex", SqlDbType.NVarChar).Value = dt.Rows[i]["性别"].ToString();
                    MyCommand.Parameters.Add("@ar_birth", SqlDbType.NVarChar).Value = dt.Rows[i]["出生年月"].ToString();
                    if ("否".Equals(dt.Rows[i]["是否转出"].ToString()))
                        MyCommand.Parameters.Add("@ar_state", SqlDbType.Int).Value = 0;
                    else if ("是".Equals(dt.Rows[i]["是否转出"].ToString()))
                        MyCommand.Parameters.Add("@ar_state", SqlDbType.Int).Value = 1;
                    else
                        MyCommand.Parameters.Add("@ar_state", SqlDbType.Int).Value = DBNull.Value;
                    MyCommand.Parameters.Add("@ar_inserttime", SqlDbType.NVarChar).Value = dt.Rows[i]["入库日期"].ToString();
                    MyCommand.Parameters.Add("@ar_school", SqlDbType.NVarChar).Value = dt.Rows[i]["毕业院校"].ToString();
                    MyCommand.Parameters.Add("@ar_card", SqlDbType.NVarChar).Value = dt.Rows[i]["身份证号"].ToString();
                    res = MyCommand.ExecuteNonQuery();
                    if (res > 0)
                        count++;
                    MyCommand.Parameters.Clear();
                }
            }
            WriteLog(uid, 1, ip, "用户【" + name + "】，在档案管理功能中进行了档案信息导入操作，总计：【" + count + "】人。", MyCommand);
            MyTrans.Commit();
        }
        catch
        {
            MyTrans.Rollback("Tran");
            res = -1;
        }
        Close();
        return res;
    }

    public int SaveScore(string uid, string name, string ip, DataTable dt)
    {
        int res = 0;
        Open();
        SqlCommand MyCommand = MyConnection.CreateCommand();
        SqlTransaction MyTrans;
        MyTrans = MyConnection.BeginTransaction("Tran");
        MyCommand.Connection = MyConnection;
        MyCommand.Transaction = MyTrans;
        try
        {
            int count = 0;
            if (dt.Rows.Count > 0)
            {
                MyCommand.CommandText = "truncate table Score";
                MyCommand.ExecuteNonQuery();
            }
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                string value = dt.Rows[i]["招考单位"].ToString() + dt.Rows[i]["报考岗位"].ToString() + dt.Rows[i]["报考科目"].ToString() + dt.Rows[i]["准考证号"].ToString() + dt.Rows[i]["姓名"].ToString() + dt.Rows[i]["身份证号码"].ToString() + dt.Rows[i]["成绩"].ToString() + dt.Rows[i]["备注"].ToString();
                if (!string.IsNullOrEmpty(value))
                {
                    MyCommand.CommandText = "insert into Score (sc_company,sc_job,sc_kemu,sc_number,sc_name,sc_cardid,sc_score,sc_memo) values (@sc_company,@sc_job,@sc_kemu,@sc_number,@sc_name,@sc_cardid,@sc_score,@sc_memo)";
                    MyCommand.Parameters.Add("@sc_company", SqlDbType.NVarChar).Value = dt.Rows[i]["招考单位"].ToString();
                    MyCommand.Parameters.Add("@sc_job", SqlDbType.NVarChar).Value = dt.Rows[i]["报考岗位"].ToString();
                    MyCommand.Parameters.Add("@sc_kemu", SqlDbType.NVarChar).Value = dt.Rows[i]["报考科目"].ToString();
                    MyCommand.Parameters.Add("@sc_name", SqlDbType.NVarChar).Value = dt.Rows[i]["姓名"].ToString();
                    MyCommand.Parameters.Add("@sc_number", SqlDbType.NVarChar).Value = dt.Rows[i]["准考证号"].ToString();
                    MyCommand.Parameters.Add("@sc_cardid", SqlDbType.NVarChar).Value = dt.Rows[i]["身份证号码"].ToString();
                    MyCommand.Parameters.Add("@sc_score", SqlDbType.NVarChar).Value = dt.Rows[i]["成绩"].ToString();
                    MyCommand.Parameters.Add("@sc_memo", SqlDbType.NText).Value = dt.Rows[i]["备注"].ToString();
                    res = MyCommand.ExecuteNonQuery();
                    if (res > 0)
                        count++;
                    MyCommand.Parameters.Clear();
                }
            }
            WriteLog(uid, 1, ip, "用户【" + name + "】，在事业单位考试分数管理功能中进行了事业单位考试分数导入操作，总计：【" + count + "】人。", MyCommand);
            MyTrans.Commit();
        }
        catch
        {
            MyTrans.Rollback("Tran");
            res = -1;
        }
        Close();
        return res;
    }

    public int SaveExam(Hashtable data)
    {
        int res = 0;
        Open();
        SqlCommand MyCommand = MyConnection.CreateCommand();
        SqlTransaction MyTrans;
        MyTrans = MyConnection.BeginTransaction("Tran");
        MyCommand.Connection = MyConnection;
        MyCommand.Transaction = MyTrans;
        try
        {
            MyCommand.Parameters.Add("@ex_title", SqlDbType.NVarChar).Value = data["ex_title"];
            MyCommand.Parameters.Add("@ex_table", SqlDbType.NVarChar).Value = data["ex_table"];
            MyCommand.Parameters.Add("@ex_memo", SqlDbType.NText).Value = data["ex_memo"];
            MyCommand.Parameters.Add("@user", SqlDbType.BigInt).Value = data["user"];
            MyCommand.Parameters.Add("@ip", SqlDbType.NVarChar).Value = data["ip"];

            if (string.IsNullOrEmpty(data["ex_no"].ToString()))
            {
                MyCommand.CommandText = " insert into exam (ex_title,ex_table,ex_state,ex_time,ex_user,ex_ip,ex_memo) values (@ex_title,@ex_table,1,getdate(),@user,@ip,@ex_memo)";
                res = MyCommand.ExecuteNonQuery();
                if (res > 0)
                {
                    WriteLog(data["user"].ToString(), 1, data["ip"].ToString(), "用户【" + data["name"].ToString() + "】，在分数导入功能中进行了新增操作，新增记录为【标题：" + data["ex_title"] + "】。", MyCommand);
                    res = 1;
                }
                else
                    res = -1;
            }

            MyTrans.Commit();
        }
        catch
        {
            MyTrans.Rollback("Tran");
            res = -1;
        }
        Close();
        return res;
    }

    public int LockExam(string uid, string name, string ip, string ex_no, string ex_state)
    {
        int res = 0;
        Open();
        SqlCommand MyCommand = MyConnection.CreateCommand();
        SqlTransaction MyTrans = MyConnection.BeginTransaction("Tran");
        MyCommand.Connection = MyConnection;
        MyCommand.Transaction = MyTrans;
        try
        {
            string[] id = ex_no.Split(',');
            for (int i = 0; i < id.Length; i++)
            {
                MyCommand.CommandText = " select * from exam where ex_no=@ex_no ";
                MyCommand.Parameters.Add("@ex_no", SqlDbType.BigInt).Value = id[i];
                DataTable dt = new DataTable();
                SqlDataAdapter da = new SqlDataAdapter(MyCommand);
                da.Fill(dt);
                if (dt != null && dt.Rows.Count > 0)
                {
                    string memo = "";
                    if (!ex_state.Equals(dt.Rows[0]["ex_state"].ToString()))
                    {
                        string s1 = "隐藏";
                        if (ConfigurationManager.AppSettings["Open"].Equals(dt.Rows[0]["ex_state"].ToString()))
                            s1 = "显示";
                        string s2 = "隐藏";
                        if (ConfigurationManager.AppSettings["Open"].Equals(ex_state))
                            s2 = "显示";
                        memo = "考试分数：" + dt.Rows[0]["ex_title"].ToString() + "，将状态从[" + s1 + "]改为[" + s2 + "]";
                    }
                    if (string.IsNullOrEmpty(memo))
                        memo = "考试分数：" + dt.Rows[0]["ex_title"].ToString() + "，未修改任何字段";
                    MyCommand.CommandText = "update exam set ex_state=@ex_state where ex_no=@ex_no ";
                    MyCommand.Parameters.Add("@ex_state", SqlDbType.Int).Value = ex_state;
                    res = MyCommand.ExecuteNonQuery();
                    if (res > 0)
                        WriteLog(uid, 2, ip, "用户【" + name + "】，在分数导入管理功能中进行了数据修改操作，修改记录为【" + memo + "】。", MyCommand);
                }
                MyCommand.Parameters.Clear();
            }
            MyTrans.Commit();
            res = 1;
        }
        catch (Exception ex)
        {
            MyTrans.Rollback("Tran");
            res = -1;
        }
        Close();
        return res;
    }

    public DataTable GetSJobCount(string table, string where)
    {
        Open();
        SqlCommand MyCommand = new SqlCommand();
        MyCommand.Connection = MyConnection;

        MyCommand.CommandText = "select count(re_no) as jobcount from " + table + " where " + where;
        DataTable data = new DataTable();
        SqlDataAdapter adapter = new SqlDataAdapter(MyCommand);
        adapter.Fill(data);
        Close();
        return data;
    }

    public DataTable GetSJobCountByType(string type, string sdate, string edate)
    {
        Open();
        SqlCommand MyCommand = new SqlCommand();
        MyCommand.Connection = MyConnection;
        if (!string.IsNullOrEmpty(type) && !"0".Equals(type))
            MyCommand.CommandText = " select count(re_no) as jobcount from recruit inner join jobtype on jt_id=re_jobtype11 where re_state=1 and re_jobtype1='" + type + "'";
        else
            MyCommand.CommandText = " select count(re_no) as jobcount from recruit inner join jobtype on jt_id=re_jobtype1 where re_state=1 and jt_pid='0'";
        if (!string.IsNullOrEmpty(sdate))
            MyCommand.CommandText += " and re_inserttime>='" + sdate + "'";
        if (!string.IsNullOrEmpty(edate))
            MyCommand.CommandText += " and re_inserttime<='" + edate + "'";
        DataTable data = new DataTable();
        SqlDataAdapter adapter = new SqlDataAdapter(MyCommand);
        adapter.Fill(data);
        Close();
        return data;
    }

    public DataTable GetSJobCountByEdu(string sdate, string edate)
    {
        Open();
        SqlCommand MyCommand = new SqlCommand();
        MyCommand.Connection = MyConnection;
        MyCommand.CommandText = " select count(re_no) as jobcount from recruit inner join dictionary on di_code=re_edu and di_type=4 where re_state=1 ";
        if (!string.IsNullOrEmpty(sdate))
            MyCommand.CommandText += " and re_inserttime>='" + sdate + "'";
        if (!string.IsNullOrEmpty(edate))
            MyCommand.CommandText += " and re_inserttime<='" + edate + "'";
        DataTable data = new DataTable();
        SqlDataAdapter adapter = new SqlDataAdapter(MyCommand);
        adapter.Fill(data);
        Close();
        return data;
    }

    public DataTable GetSNeedCountByType(string type, string sdate, string edate)
    {
        Open();
        SqlCommand MyCommand = new SqlCommand();
        MyCommand.Connection = MyConnection;
        if (!string.IsNullOrEmpty(type) && !"0".Equals(type))
            MyCommand.CommandText = " select count(re_no) as jobcount from recruit left join jobtype on jt_id=re_jobtype11 where re_need=1 and re_needstate=1 and re_jobtype1='" + type + "'";
        else
            MyCommand.CommandText = " select count(re_no) as jobcount from recruit left join jobtype on jt_id=re_jobtype1 where re_need=1 and re_needstate=1 ";
        if (!string.IsNullOrEmpty(sdate))
            MyCommand.CommandText += " and re_inserttime>='" + sdate + "'";
        if (!string.IsNullOrEmpty(edate))
            MyCommand.CommandText += " and re_inserttime<='" + edate + "'";
        DataTable data = new DataTable();
        SqlDataAdapter adapter = new SqlDataAdapter(MyCommand);
        adapter.Fill(data);
        Close();
        return data;
    }

    public DataTable GetSNeedCountByEdu(string sdate, string edate)
    {
        Open();
        SqlCommand MyCommand = new SqlCommand();
        MyCommand.Connection = MyConnection;
        MyCommand.CommandText = " select count(re_no) as jobcount from recruit inner join dictionary on di_code=re_edu and di_type=4 where re_need=1 and re_needstate=1 ";
        if (!string.IsNullOrEmpty(sdate))
            MyCommand.CommandText += " and re_inserttime>='" + sdate + "'";
        if (!string.IsNullOrEmpty(edate))
            MyCommand.CommandText += " and re_inserttime<='" + edate + "'";
        DataTable data = new DataTable();
        SqlDataAdapter adapter = new SqlDataAdapter(MyCommand);
        adapter.Fill(data);
        Close();
        return data;
    }

    public DataTable GetSPersonCount(string table, string where)
    {
        Open();
        SqlCommand MyCommand = new SqlCommand();
        MyCommand.Connection = MyConnection;

        MyCommand.CommandText = "select count(pi_no) as personcount from " + table + " where " + where;
        DataTable data = new DataTable();
        SqlDataAdapter adapter = new SqlDataAdapter(MyCommand);
        adapter.Fill(data);
        Close();
        return data;
    }

    public DataTable GetSPersonCountByMajor(string type, string sdate, string edate)
    {
        Open();
        SqlCommand MyCommand = new SqlCommand();
        MyCommand.Connection = MyConnection;
        string where = " where pi_state=1 ";
        if (!string.IsNullOrEmpty(type) && !"0".Equals(type))
            where += " and ma_id1='" + type + "'";
        if (!string.IsNullOrEmpty(sdate))
            where += " and pi_lastchgtime>='" + sdate + "'";
        if (!string.IsNullOrEmpty(edate))
            where += " and pi_lastchgtime<='" + edate + "'";
        MyCommand.CommandText = "select count(pi_no) as pi_count from personinfor inner join View_major on ma_id2=pi_spcode " + where;

        DataTable data = new DataTable();
        SqlDataAdapter adapter = new SqlDataAdapter(MyCommand);
        adapter.Fill(data);
        Close();
        return data;
    }

    public DataTable GetSPersonCountByYX(string type, string sdate, string edate)
    {
        Open();
        SqlCommand MyCommand = new SqlCommand();
        MyCommand.Connection = MyConnection;
        string table = "";
        string where = "";
        if (!string.IsNullOrEmpty(type) && !"0".Equals(type))
        {
            table = " from personinfor inner join jobtype on jt_id=pi_yx11 ";
            where = " where pi_state=1 and pi_yx1='" + type + "'";
        }
        else
        {
            table = " from personinfor inner join jobtype on jt_id=pi_yx1 ";
            where = " where pi_state=1 and jt_pid='0'";
        }
        if (!string.IsNullOrEmpty(sdate))
            where += " and pi_lastchgtime>='" + sdate + "'";
        if (!string.IsNullOrEmpty(edate))
            where += " and pi_lastchgtime<='" + edate + "'";
        MyCommand.CommandText = "select count(pi_no) as pi_count " + table + where;

        DataTable data = new DataTable();
        SqlDataAdapter adapter = new SqlDataAdapter(MyCommand);
        adapter.Fill(data);
        Close();
        return data;
    }

    public DataTable GetSPersonCountByEdu(string sdate, string edate)
    {
        Open();
        SqlCommand MyCommand = new SqlCommand();
        MyCommand.Connection = MyConnection;
        MyCommand.CommandText = " select count(pi_no) as pi_count from personinfor inner join dictionary on di_code=pi_edu and di_type=4 where pi_state=1 ";
        if (!string.IsNullOrEmpty(sdate))
            MyCommand.CommandText += " and pi_lastchgtime>='" + sdate + "'";
        if (!string.IsNullOrEmpty(edate))
            MyCommand.CommandText += " and pi_lastchgtime<='" + edate + "'";
        DataTable data = new DataTable();
        SqlDataAdapter adapter = new SqlDataAdapter(MyCommand);
        adapter.Fill(data);
        Close();
        return data;
    }

    public DataTable GetSHighCountByMajor(string type, string sdate, string edate)
    {
        Open();
        SqlCommand MyCommand = new SqlCommand();
        MyCommand.Connection = MyConnection;
        string where = " where pi_state=1 and (pi_edu in ('7','8','9') or pi_zhicheng in ('中级职称','高级职称')) ";
        if (!string.IsNullOrEmpty(type) && !"0".Equals(type))
            where += " and ma_id1='" + type + "'";
        if (!string.IsNullOrEmpty(sdate))
            where += " and pi_lastchgtime>='" + sdate + "'";
        if (!string.IsNullOrEmpty(edate))
            where += " and pi_lastchgtime<='" + edate + "'";
        MyCommand.CommandText = "select count(pi_no) as pi_count from personinfor inner join View_major on ma_id2=pi_spcode " + where;

        DataTable data = new DataTable();
        SqlDataAdapter adapter = new SqlDataAdapter(MyCommand);
        adapter.Fill(data);
        Close();
        return data;
    }

    public DataTable GetSHighCountByYX(string type, string sdate, string edate)
    {
        Open();
        SqlCommand MyCommand = new SqlCommand();
        MyCommand.Connection = MyConnection;
        string table = "";
        string where = "";
        if (!string.IsNullOrEmpty(type) && !"0".Equals(type))
        {
            table = " from personinfor inner join jobtype on jt_id=pi_yx11 ";
            where = " where pi_state=1 and (pi_edu in ('7','8','9') or pi_zhicheng in ('中级职称','高级职称')) and pi_yx1='" + type + "'";
        }
        else
        {
            table = " from personinfor inner join jobtype on jt_id=pi_yx1 ";
            where = " where pi_state=1 and (pi_edu in ('7','8','9') or pi_zhicheng in ('中级职称','高级职称')) and jt_pid='0'";
        }
        if (!string.IsNullOrEmpty(sdate))
            where += " and pi_lastchgtime>='" + sdate + "'";
        if (!string.IsNullOrEmpty(edate))
            where += " and pi_lastchgtime<='" + edate + "'";
        MyCommand.CommandText = "select count(pi_no) as pi_count " + table + where;

        DataTable data = new DataTable();
        SqlDataAdapter adapter = new SqlDataAdapter(MyCommand);
        adapter.Fill(data);
        Close();
        return data;
    }

    public DataTable GetSHighCountByEdu(string sdate, string edate)
    {
        Open();
        SqlCommand MyCommand = new SqlCommand();
        MyCommand.Connection = MyConnection;
        MyCommand.CommandText = " select count(pi_no) as pi_count from personinfor inner join dictionary on di_code=pi_edu and di_type=4 where pi_state=1 and (pi_edu in ('7','8','9') or pi_zhicheng in ('中级职称','高级职称')) ";
        if (!string.IsNullOrEmpty(sdate))
            MyCommand.CommandText += " and pi_lastchgtime>='" + sdate + "'";
        if (!string.IsNullOrEmpty(edate))
            MyCommand.CommandText += " and pi_lastchgtime<='" + edate + "'";
        DataTable data = new DataTable();
        SqlDataAdapter adapter = new SqlDataAdapter(MyCommand);
        adapter.Fill(data);
        Close();
        return data;
    }

    public DataTable GetSCompanyCount(string table, string where)
    {
        Open();
        SqlCommand MyCommand = new SqlCommand();
        MyCommand.Connection = MyConnection;

        MyCommand.CommandText = "select count(cu_no) as companycount from " + table + " where " + where;
        DataTable data = new DataTable();
        SqlDataAdapter adapter = new SqlDataAdapter(MyCommand);
        adapter.Fill(data);
        Close();
        return data;
    }

    public DataTable GetSCompanyCountByTrade(string sdate, string edate)
    {
        Open();
        SqlCommand MyCommand = new SqlCommand();
        MyCommand.Connection = MyConnection;
        MyCommand.CommandText = " select count(cu_no) as cu_count from companyuser inner join dictionary on di_code=cu_trade and di_type=1 where cu_state=1 ";
        if (!string.IsNullOrEmpty(sdate))
            MyCommand.CommandText += " and cu_apptime>='" + sdate + "'";
        if (!string.IsNullOrEmpty(edate))
            MyCommand.CommandText += " and cu_apptime<='" + edate + "'";
        DataTable data = new DataTable();
        SqlDataAdapter adapter = new SqlDataAdapter(MyCommand);
        adapter.Fill(data);
        Close();
        return data;
    }

    public string GetPersonName(string pi_no)
    {
        string res = "";
        Open();
        try
        {
            SqlCommand MyCommand = new SqlCommand("select pi_name from personinfor,findwork where pi_no=fw_pino and pi_no=@pi_no", MyConnection);
            MyCommand.Parameters.Add("@pi_no", SqlDbType.BigInt).Value = pi_no;
            res = MyCommand.ExecuteScalar().ToString();
        }
        catch (Exception e)
        {

        }
        Close();
        return res;
    }

    public int SaveMobileMsg(Hashtable data)
    {
        Int64 res = 0;
        Open();
        SqlCommand MyCommand = MyConnection.CreateCommand();
        SqlTransaction MyTrans = MyConnection.BeginTransaction("Tran");
        MyCommand.Connection = MyConnection;
        MyCommand.Transaction = MyTrans;
        try
        {
            MyCommand.Parameters.Add("@mm_title", SqlDbType.NVarChar).Value = data["mm_title"];
            MyCommand.Parameters.Add("@mm_memo", SqlDbType.NText).Value = data["mm_memo"];
            MyCommand.Parameters.Add("@user", SqlDbType.BigInt).Value = data["user"];
            MyCommand.Parameters.Add("@ip", SqlDbType.NVarChar).Value = data["ip"];
            MyCommand.CommandText = " insert into mobilemsg (mm_type,mm_title,mm_memo,mm_sendtime,mm_user,mm_ip) values (0,@mm_title,@mm_memo,getdate(),@user,@ip);select @@Identity ";
            res = Convert.ToInt64(MyCommand.ExecuteScalar());
            if (res > 0)
                WriteLog(data["user"].ToString(), 1, data["ip"].ToString(), "用户【" + data["name"].ToString() + "】，在短信发送功能中进行了数据新增操作，新增记录为【标题：" + data["mm_title"] + "】。", MyCommand);
            string[] id = data["pi_no"].ToString().Split(',');
            for (int i = 0; i < id.Length; i++)
            {
                MyCommand.CommandText = " insert into receiveperson (rp_mmno,rp_pino) values (@rp_mmno,@rp_pino) ";
                MyCommand.Parameters.Add("@rp_pino", SqlDbType.BigInt).Value = id[i];
                MyCommand.Parameters.Add("@rp_mmno", SqlDbType.BigInt).Value = res;
                MyCommand.ExecuteNonQuery();
                MyCommand.Parameters.Clear();
            }
            MyTrans.Commit();
            Close();
            return 1;
        }
        catch (Exception ex)
        {
            MyTrans.Rollback("Tran");
            Close();
            return -1;
        }
    }

    public int SendMobileMsg(Hashtable data)
    {
        Int64 res = 0;
        Open();
        SqlCommand MyCommand = MyConnection.CreateCommand();
        SqlTransaction MyTrans = MyConnection.BeginTransaction("Tran");
        MyCommand.Connection = MyConnection;
        MyCommand.Transaction = MyTrans;
        try
        {
            MyCommand.Parameters.Add("@mm_title", SqlDbType.NVarChar).Value = data["mm_title"];
            MyCommand.Parameters.Add("@mm_memo", SqlDbType.NText).Value = data["mm_memo"];
            MyCommand.Parameters.Add("@user", SqlDbType.BigInt).Value = data["user"];
            MyCommand.Parameters.Add("@ip", SqlDbType.NVarChar).Value = data["ip"];
            MyCommand.CommandText = " insert into mobilemsg (mm_type,mm_title,mm_memo,mm_sendtime,mm_user,mm_ip) values (0,@mm_title,@mm_memo,getdate(),@user,@ip);select @@Identity ";
            res = Convert.ToInt64(MyCommand.ExecuteScalar());
            if (res > 0)
                WriteLog(data["user"].ToString(), 1, data["ip"].ToString(), "用户【" + data["name"].ToString() + "】，在短信发送功能中进行了数据新增操作，新增记录为【标题：" + data["mm_title"] + "】。", MyCommand);
            string[] id = data["pi_no"].ToString().Split(',');
            for (int i = 0; i < id.Length; i++)
            {
                MyCommand.CommandText = " insert into receiveperson (rp_mmno,rp_pino) values (@rp_mmno,@rp_pino) ";
                MyCommand.Parameters.Add("@rp_pino", SqlDbType.BigInt).Value = id[i];
                MyCommand.Parameters.Add("@rp_mmno", SqlDbType.BigInt).Value = res;
                MyCommand.ExecuteNonQuery();
                MyCommand.Parameters.Clear();
            }
            MyTrans.Commit();
            Close();
            return 1;
        }
        catch (Exception ex)
        {
            MyTrans.Rollback("Tran");
            Close();
            return -1;
        }
    }

    public int SendMobileMsg(string uid, string name, string ip, string pi_no)
    {
        int res = 0;
        Open();
        SqlCommand MyCommand = MyConnection.CreateCommand();
        SqlTransaction MyTrans = MyConnection.BeginTransaction("Tran");
        MyCommand.Connection = MyConnection;
        MyCommand.Transaction = MyTrans;
        try
        {
            string[] id = pi_no.Split(',');
            for (int i = 0; i < id.Length; i++)
            {
                MyCommand.CommandText = " select pi_name,pi_yx1,pi_yx11,pi_yx2,pi_yx22,pi_workarea from personinfor where pi_no=@pi_no ";
                MyCommand.Parameters.Add("@pi_no", SqlDbType.BigInt).Value = id[i];
                DataTable dt = new DataTable();
                SqlDataAdapter da = new SqlDataAdapter(MyCommand);
                da.Fill(dt);
                if (dt != null && dt.Rows.Count > 0)
                {
                    string where = " re_delete<>1 and re_hide<>1 and re_state=1 and DATEADD(DAY,re_effecttime,re_inserttime)>=GETDATE() ";
                    string yx = "";
                    if (!string.IsNullOrEmpty(dt.Rows[0]["pi_yx22"].ToString()))
                    {
                        yx = "re_jobtype11='" + dt.Rows[0]["pi_yx22"].ToString() + "' or re_jobtype22='" + dt.Rows[0]["pi_yx22"].ToString() + "'"; ;
                        if (!string.IsNullOrEmpty(dt.Rows[0]["pi_yx11"].ToString()))
                            yx += " or re_jobtype11='" + dt.Rows[0]["pi_yx11"].ToString() + "' or re_jobtype22='" + dt.Rows[0]["pi_yx11"].ToString() + "'";
                        else
                        {
                            if (!string.IsNullOrEmpty(dt.Rows[0]["pi_yx1"].ToString()))
                                yx += " or re_jobtype1='" + dt.Rows[0]["pi_yx1"].ToString() + "' or re_jobtype2='" + dt.Rows[0]["pi_yx1"].ToString() + "'"; ;
                        }
                    }
                    else
                    {
                        if (!string.IsNullOrEmpty(dt.Rows[0]["pi_yx2"].ToString()))
                        {
                            yx = "re_jobtype1='" + dt.Rows[0]["pi_yx2"].ToString() + "' or re_jobtype2='" + dt.Rows[0]["pi_yx2"].ToString() + "'";
                            if (!string.IsNullOrEmpty(dt.Rows[0]["pi_yx11"].ToString()))
                                yx += " or re_jobtype11='" + dt.Rows[0]["pi_yx11"].ToString() + "' or re_jobtype22='" + dt.Rows[0]["pi_yx11"].ToString() + "'";
                            else
                            {
                                if (!string.IsNullOrEmpty(dt.Rows[0]["pi_yx1"].ToString()))
                                    yx += " or re_jobtype1='" + dt.Rows[0]["pi_yx1"].ToString() + "' or re_jobtype2='" + dt.Rows[0]["pi_yx1"].ToString() + "'";
                            }
                        }
                        else
                        {
                            if (!string.IsNullOrEmpty(dt.Rows[0]["pi_yx11"].ToString()))
                                yx = " re_jobtype11='" + dt.Rows[0]["pi_yx11"].ToString() + "' or re_jobtype22='" + dt.Rows[0]["pi_yx11"].ToString() + "'";
                            else
                            {
                                if (!string.IsNullOrEmpty(dt.Rows[0]["pi_yx1"].ToString()))
                                    yx = " re_jobtype1='" + dt.Rows[0]["pi_yx1"].ToString() + "' or re_jobtype2='" + dt.Rows[0]["pi_yx1"].ToString() + "'";
                            }
                        }
                    }
                    if (!string.IsNullOrEmpty(yx))
                        where += " and (" + yx + ")";
                    if (!string.IsNullOrEmpty(dt.Rows[0]["pi_workarea"].ToString()) && !"999999".Equals(dt.Rows[0]["pi_workarea"].ToString()))
                        where += " and re_area='" + dt.Rows[0]["pi_workarea"].ToString() + "'";

                    MyCommand.CommandText = " select top 5 cu_name,re_name from recruit left join companyuser on re_cuno=cu_no where " + where;
                    DataTable dt2 = new DataTable();
                    SqlDataAdapter da2 = new SqlDataAdapter(MyCommand);
                    da2.Fill(dt2);
                    if (dt2 != null && dt2.Rows.Count > 0)
                    {
                        string memo = "尊敬的湖州人才网个人用户：您开通了湖州人才网短信找工作业务，以下招聘岗位：";
                        for (int j = 0; j < dt2.Rows.Count; j++)
                        {
                            if (j != dt2.Rows.Count - 1)
                                memo += "单位：" + dt2.Rows[j]["cu_name"].ToString() + "，岗位：" + dt2.Rows[j]["re_name"].ToString() + "；";
                            else
                                memo += "单位：" + dt2.Rows[j]["cu_name"].ToString() + "，岗位：" + dt2.Rows[j]["re_name"].ToString() + "。";
                        }
                        memo += "希望对您找工作有所帮助！详见湖州人才网:http://www.hzhr.com/Web/Company/List.html";
                        MyCommand.Parameters.Add("@mm_title", SqlDbType.NVarChar).Value = dt.Rows[0]["pi_name"].ToString() + "短信找工作";
                        MyCommand.Parameters.Add("@mm_memo", SqlDbType.NText).Value = memo;
                        MyCommand.Parameters.Add("@user", SqlDbType.BigInt).Value = uid;
                        MyCommand.Parameters.Add("@ip", SqlDbType.NVarChar).Value = ip;
                        MyCommand.CommandText = " insert into mobilemsg (mm_type,mm_title,mm_memo,mm_sendtime,mm_user,mm_ip) values (0,@mm_title,@mm_memo,getdate(),@user,@ip);select @@Identity ";
                        Int64 ret = Convert.ToInt64(MyCommand.ExecuteScalar());
                        if (ret > 0)
                            WriteLog(uid, 1, ip, "用户【" + name + "】，在短信发送功能中进行了数据新增操作，新增记录为【标题：" + dt.Rows[0]["pi_name"].ToString() + "短信找工作】。", MyCommand);
                        MyCommand.CommandText = " insert into receiveperson (rp_mmno,rp_pino) values (@rp_mmno,@rp_pino) ";
                        MyCommand.Parameters.Add("@rp_pino", SqlDbType.BigInt).Value = id[i];
                        MyCommand.Parameters.Add("@rp_mmno", SqlDbType.BigInt).Value = ret;
                        MyCommand.ExecuteNonQuery();
                        MyCommand.Parameters.Clear();
                    }
                }
                MyCommand.Parameters.Clear();
            }
            MyTrans.Commit();
            res = 1;
        }
        catch (Exception ex)
        {
            MyTrans.Rollback("Tran");
            res = -1;
        }
        Close();
        return res;
    }

    public DataTable GetPersonTelList(string key, string state, string type, string edu, string sdate, string edate, string yx1, string yx2, string major1, string major2)
    {
        Open();
        SqlCommand MyCommand = new SqlCommand();
        MyCommand.Connection = MyConnection;
        string sql = " select pi_name,pi_mobile,fw_mobile from personinfor left join findwork on pi_no=fw_pino left join View_major on ma_id2=pi_spcode where pi_name is not null and pi_name<>'' and ((pi_mobile is not null and pi_mobile<>'') or (fw_mobile is not null and fw_mobile<>''))";
        if (!string.IsNullOrEmpty(key))
            sql += " and (pi_user like '%" + key + "%' or pi_name like '%" + key + "%')";
        if (!string.IsNullOrEmpty(state) && !"-1".Equals(state))
            sql += " and pi_state=" + state;
        if (!string.IsNullOrEmpty(type) && !"-1".Equals(type))
            sql += " and pi_hide=" + type;
        if (!string.IsNullOrEmpty(edu) && !"0".Equals(edu))
            sql += " and pi_edu='" + edu + "'";
        if (!string.IsNullOrEmpty(sdate))
            sql += " and pi_logintime>='" + sdate + "'";
        if (!string.IsNullOrEmpty(edate))
            sql += " and pi_logintime<='" + edate + "'";
        if (!string.IsNullOrEmpty(yx1) && !"0".Equals(yx1))
            sql += " and (pi_yx1='" + yx1 + "' or pi_yx2='" + yx1 + "')";
        if (!string.IsNullOrEmpty(yx2) && !"0".Equals(yx2))
            sql += " and (pi_yx11='" + yx2 + "' or pi_yx22='" + yx2 + "')";
        if (!string.IsNullOrEmpty(major1) && !"0".Equals(major1))
            sql += " and ma_id1='" + major1 + "'";
        if (!string.IsNullOrEmpty(major2) && !"0".Equals(major2))
            sql += " and pi_spcode='" + major2 + "'";

        MyCommand.CommandText = sql + " order by pi_no desc ";

        DataTable data = new DataTable();
        SqlDataAdapter adapter = new SqlDataAdapter(MyCommand);
        adapter.Fill(data);
        Close();
        return data;
    }

    public DataTable GetPersonTelList(string type1, string type2, string major1, string major2, string edu, string sdate, string edate)
    {
        Open();
        SqlCommand MyCommand = new SqlCommand();
        MyCommand.Connection = MyConnection;
        string sql = " select pi_name,pi_mobile,fw_mobile from personinfor left join findwork on pi_no=fw_pino left join View_major on ma_id2=pi_spcode where pi_state=1 and ((pi_mobile is not null and pi_mobile<>'') or (fw_mobile is not null and fw_mobile<>'')) ";
        if (!string.IsNullOrEmpty(type1) && !"0".Equals(type1))
            sql += " and (pi_yx1='" + type1 + "' or pi_yx2='" + type1 + "')";
        if (!string.IsNullOrEmpty(type2) && !"0".Equals(type2))
            sql += " and (pi_yx11='" + type2 + "' or pi_yx22='" + type2 + "')";
        if (!string.IsNullOrEmpty(major1) && !"0".Equals(major1))
            sql += " and ma_id1='" + major1 + "'";
        if (!string.IsNullOrEmpty(major2) && !"0".Equals(major2))
            sql += " and pi_spcode='" + major2 + "'";
        if (!string.IsNullOrEmpty(edu) && !"0".Equals(edu))
            sql += " and pi_edu='" + edu + "'";
        if (!string.IsNullOrEmpty(sdate))
            sql += " and pi_logintime>='" + sdate + "'";
        if (!string.IsNullOrEmpty(edate))
            sql += " and pi_logintime<='" + edate + "'";

        MyCommand.CommandText = sql + " order by pi_no desc ";

        DataTable data = new DataTable();
        SqlDataAdapter adapter = new SqlDataAdapter(MyCommand);
        adapter.Fill(data);
        Close();
        return data;
    }

    public DataTable GetCompanyTelList(string key, string level, string state, string type, string sdate, string edate, string trade, string property, string area, string logins, string logine)
    {
        Open();
        SqlCommand MyCommand = new SqlCommand();
        MyCommand.Connection = MyConnection;
        string sql = " select cu_name,cu_msgname,cu_msgmobile from companyuser where cu_no>0 and cu_msgmobile is not null and cu_msgmobile<>''";
        if (!string.IsNullOrEmpty(key))
            sql += " and (cu_name like '%" + key + "%' or cu_user like '%" + key + "%')";
        if (!string.IsNullOrEmpty(level) && !"0".Equals(level))
            sql += " and cu_kind=" + level;
        if (!string.IsNullOrEmpty(type) && !"0".Equals(type))
        {
            if ("1".Equals(type))
                sql += " and cu_state = 1 and DATEADD(DAY,cu_effecttime,cu_apptime)>=GETDATE()";
            else if ("-1".Equals(type))
                sql += " and cu_state = 1 and DATEADD(DAY,cu_effecttime,cu_apptime)<GETDATE()";
            else if ("2".Equals(type))
                sql += " and cu_state = 1 and DATEADD(DAY,cu_effecttime,cu_apptime)>=GETDATE() and DATEADD(DAY,(cu_effecttime-15),cu_apptime)<=GETDATE()";
        }
        if (!string.IsNullOrEmpty(state) && !"-1".Equals(state))
            sql += " and cu_state=" + state;
        if (!string.IsNullOrEmpty(sdate))
            sql += " and cu_apptime>='" + sdate + "'";
        if (!string.IsNullOrEmpty(edate))
            sql += " and cu_apptime<='" + edate + "'";
        if (!string.IsNullOrEmpty(trade) && !"0".Equals(trade))
            sql += " and cu_trade='" + trade + "'";
        if (!string.IsNullOrEmpty(property) && !"0".Equals(property))
            sql += " and cu_property='" + property + "'";
        if (!string.IsNullOrEmpty(area) && !"0".Equals(area))
            sql += " and cu_area='" + area + "'";
        if (!string.IsNullOrEmpty(logins))
            sql += " and cu_logintime>='" + logins + "'";
        if (!string.IsNullOrEmpty(logine))
            sql += " and cu_logintime<='" + logine + "'";

        MyCommand.CommandText = sql + " order by cu_no desc ";

        DataTable data = new DataTable();
        SqlDataAdapter adapter = new SqlDataAdapter(MyCommand);
        adapter.Fill(data);
        Close();
        return data;
    }

    public DataTable GetDelayJobCount(string table, string where)
    {
        Open();
        SqlCommand MyCommand = new SqlCommand();
        MyCommand.Connection = MyConnection;

        MyCommand.CommandText = "select count(rr_no) as jobcount from " + table + " where " + where;
        DataTable data = new DataTable();
        SqlDataAdapter adapter = new SqlDataAdapter(MyCommand);
        adapter.Fill(data);
        Close();
        return data;
    }

    public DataTable GetSDelayByTypeList(string type, string sdate, string edate)
    {
        Open();
        SqlCommand MyCommand = new SqlCommand();
        MyCommand.Connection = MyConnection;
        string table = "";
        string where = " 1=1 ";

        if (!string.IsNullOrEmpty(type) && !"0".Equals(type))
        {
            where += " and re_jobtype1=" + type;
            table = " recruitrefresh  left join recruit on re_no=rr_reno inner join jobtype on jt_id=re_jobtype11 ";
        }
        else
        {
            //where += " and jt_pid='0'";
            table = " recruitrefresh  left join recruit on re_no=rr_reno inner join jobtype on jt_id=re_jobtype1 ";
        }

        if (!string.IsNullOrEmpty(sdate))
            where += " and re_inserttime>='" + sdate + "'";
        if (!string.IsNullOrEmpty(edate))
            where += " and re_inserttime<='" + edate + "'";
        MyCommand.CommandText = " select jt_id,jt_name,count(rr_reno) as re_count,(cast((cast(count(rr_reno) as float)*100/(select case when count(rr_reno)=0 then 1 else count(rr_reno) end from " + table + " where " + where + ")) as numeric(5,2))) as re_percent from " + table + " where " + where;
        MyCommand.CommandText += " group by jt_id,jt_name order by re_count desc ";
        DataTable data = new DataTable();
        SqlDataAdapter adapter = new SqlDataAdapter(MyCommand);
        adapter.Fill(data);
        Close();
        return data;
    }

    public DataTable GetSDelayCountByType(string type, string sdate, string edate)
    {
        Open();
        SqlCommand MyCommand = new SqlCommand();
        MyCommand.Connection = MyConnection;
        if (!string.IsNullOrEmpty(type) && !"0".Equals(type))
            MyCommand.CommandText = " select count(rr_no) as jobcount from recruitrefresh  left join recruit on re_no=rr_reno inner join jobtype on jt_id=re_jobtype11  where  re_jobtype1='" + type + "'";
        else
            MyCommand.CommandText = " select count(rr_no) as jobcount from recruitrefresh  left join recruit on re_no=rr_reno inner join jobtype on jt_id=re_jobtype1   where  1=1 ";
        if (!string.IsNullOrEmpty(sdate))
            MyCommand.CommandText += " and re_inserttime>='" + sdate + "'";
        if (!string.IsNullOrEmpty(edate))
            MyCommand.CommandText += " and re_inserttime<='" + edate + "'";
        DataTable data = new DataTable();
        SqlDataAdapter adapter = new SqlDataAdapter(MyCommand);
        adapter.Fill(data);
        Close();
        return data;
    }

    /// <summary>
    /// 删除橱窗招聘
    /// </summary>
    /// <param name="uid"></param>
    /// <param name="name"></param>
    /// <param name="ip"></param>
    /// <param name="re_no"></param>
    /// <returns></returns>
    public int DeleteShopWindow(string uid, string name, string ip, string sw_no)
    {
        int res = 0;
        Open();
        SqlCommand MyCommand = MyConnection.CreateCommand();
        SqlTransaction MyTrans = MyConnection.BeginTransaction("Tran");
        MyCommand.Connection = MyConnection;
        MyCommand.Transaction = MyTrans;
        try
        {
            string[] id = sw_no.Split(',');
            for (int i = 0; i < id.Length; i++)
            {
                MyCommand.CommandText = " select * from shopwindow where sw_no=@sw_no ";
                MyCommand.Parameters.Add("@sw_no", SqlDbType.BigInt).Value = id[i];
                DataTable dt = new DataTable();
                SqlDataAdapter da = new SqlDataAdapter(MyCommand);
                da.Fill(dt);
                if (dt != null && dt.Rows.Count > 0)
                {
                    string memo = "单位：" + dt.Rows[0]["sw_name"].ToString() + " 发布时间 " + dt.Rows[0]["sw_inserttime"].ToString();
                    MyCommand.CommandText = "delete from shopwindow  where sw_no=@sw_no";
                    res = MyCommand.ExecuteNonQuery();
                    if (res > 0)
                        WriteLog(uid, 3, ip, "用户【" + name + "】，在橱窗招聘审核功能中进行了橱窗招聘删除操作，删除记录为【" + memo + "】。", MyCommand);
                }
                MyCommand.Parameters.Clear();
            }
            MyTrans.Commit();
            res = 1;
        }
        catch (Exception ex)
        {
            MyTrans.Rollback("Tran");
            res = -1;
        }
        Close();
        return res;
    }

    /// <summary>
    /// 审核橱窗招聘
    /// </summary>
    /// <param name="uid"></param>
    /// <param name="name"></param>
    /// <param name="ip"></param>
    /// <param name="re_no"></param>
    /// <param name="re_needstate"></param>
    /// <returns></returns>
    public int CheckShopWindow(string uid, string name, string ip, string re_no, string sw_state)
    {
        int res = 0;
        Open();
        SqlCommand MyCommand = MyConnection.CreateCommand();
        SqlTransaction MyTrans = MyConnection.BeginTransaction("Tran");
        MyCommand.Connection = MyConnection;
        MyCommand.Transaction = MyTrans;
        try
        {
            string[] id = re_no.Split(',');
            for (int i = 0; i < id.Length; i++)
            {
                MyCommand.CommandText = " select * from shopwindow where sw_no=@sw_no ";
                MyCommand.Parameters.Add("@sw_no", SqlDbType.BigInt).Value = id[i];
                DataTable dt = new DataTable();
                SqlDataAdapter da = new SqlDataAdapter(MyCommand);
                da.Fill(dt);
                if (dt != null && dt.Rows.Count > 0)
                {
                    string memo = "";
                    if (!sw_state.Equals(dt.Rows[0]["sw_state"].ToString()))
                    {
                        string s1 = "未审核";
                        if ("1".Equals(dt.Rows[0]["sw_state"].ToString()))
                            s1 = "已审通过";
                        else if ("2".Equals(dt.Rows[0]["sw_state"].ToString()))
                            s1 = "已审未通过";
                        string s2 = "已审";
                        if ("1".Equals(sw_state))
                            s2 = "已审通过";
                        else if ("2".Equals(sw_state))
                            s1 = "已审未通过";
                        memo = "橱窗招聘：公司" + dt.Rows[0]["sw_name"].ToString() + " 发布时间 " + dt.Rows[0]["sw_inserttime"].ToString() + "，将紧缺状态从[" + s1 + "]改为[" + s2 + "]";
                    }
                    if (string.IsNullOrEmpty(memo))
                        memo = "橱窗招聘：公司" + dt.Rows[0]["sw_name"].ToString() + " 发布时间 " + dt.Rows[0]["sw_inserttime"].ToString() + "，未修改任何字段";
                    MyCommand.CommandText = "update shopwindow set sw_state=@sw_state where sw_no=@sw_no ";
                    MyCommand.Parameters.Add("@sw_state", SqlDbType.Int).Value = sw_state;
                    res = MyCommand.ExecuteNonQuery();
                    if (res > 0)
                        WriteLog(uid, 2, ip, "用户【" + name + "】，在橱窗招聘审核功能中进行了审核操作，修改记录为【" + memo + "】。", MyCommand);
                }
                MyCommand.Parameters.Clear();
            }
            MyTrans.Commit();
            res = 1;
        }
        catch (Exception ex)
        {
            MyTrans.Rollback("Tran");
            res = -1;
        }
        Close();
        return res;
    }

    /// <summary>
    /// 获取橱窗招聘列表
    /// </summary>
    /// <param name="sdate"></param>
    /// <param name="edate"></param>
    /// <returns></returns>
    public DataTable GetShopWindowList(string sdate, string edate)
    {
        Open();
        SqlCommand MyCommand = new SqlCommand();
        MyCommand.Connection = MyConnection;
        string where = " sw_state=1 ";
        if (!string.IsNullOrEmpty(sdate))
            where += " and sw_inserttime>='" + sdate + "'";
        if (!string.IsNullOrEmpty(edate))
            where += " and sw_inserttime<='" + edate + "'";
        MyCommand.CommandText = " select * from shopwindow where " + where;
        DataTable data = new DataTable();
        SqlDataAdapter adapter = new SqlDataAdapter(MyCommand);
        adapter.Fill(data);
        Close();
        return data;
    }

    /// <summary>
    /// 保存基地企业
    /// </summary>
    /// <param name="data"></param>
    /// <returns></returns>
    public int SaveBase(Hashtable data)
    {
        int res;
        Open();
        SqlCommand MyCommand = MyConnection.CreateCommand();
        SqlTransaction MyTrans;
        MyTrans = MyConnection.BeginTransaction("Tran");
        MyCommand.Connection = MyConnection;
        MyCommand.Transaction = MyTrans;
        try
        {
            MyCommand.Parameters.Add("@cu_user", SqlDbType.NVarChar).Value = data["cu_user"];
            MyCommand.Parameters.Add("@cu_name", SqlDbType.NVarChar).Value = data["cu_name"];
            MyCommand.Parameters.Add("@cu_trade", SqlDbType.NVarChar).Value = data["cu_trade"];
            MyCommand.Parameters.Add("@cu_property", SqlDbType.NVarChar).Value = data["cu_property"];
            MyCommand.Parameters.Add("@cu_license", SqlDbType.NVarChar).Value = data["cu_license"];
            MyCommand.Parameters.Add("@cu_area", SqlDbType.NVarChar).Value = data["cu_area"];
            MyCommand.Parameters.Add("@cu_address", SqlDbType.NVarChar).Value = data["cu_address"];
            MyCommand.Parameters.Add("@cu_contact", SqlDbType.NVarChar).Value = data["cu_contact"];
            MyCommand.Parameters.Add("@cu_industry", SqlDbType.NVarChar).Value = data["cu_industry"];
            MyCommand.Parameters.Add("@cu_tel", SqlDbType.NVarChar).Value = data["cu_tel"];
            MyCommand.Parameters.Add("@cu_fax", SqlDbType.NVarChar).Value = data["cu_fax"];
            MyCommand.Parameters.Add("@cu_email", SqlDbType.NVarChar).Value = data["cu_email"];
            MyCommand.Parameters.Add("@cu_url", SqlDbType.NVarChar).Value = data["cu_url"];
            MyCommand.Parameters.Add("@cu_introduce", SqlDbType.NText).Value = data["cu_introduce"];
            MyCommand.Parameters.Add("@cu_ok", SqlDbType.Int).Value = "true".Equals(data["cu_ok"]) ? "1" : "0";
            MyCommand.Parameters.Add("@cu_base", SqlDbType.Int).Value = data["cu_base"];
            MyCommand.Parameters.Add("@user", SqlDbType.NVarChar).Value = data["user"];
            MyCommand.Parameters.Add("@ip", SqlDbType.NVarChar).Value = data["ip"];

            if (string.IsNullOrEmpty(data["cu_no"].ToString()))
            {
                MyCommand.Parameters.Add("@cu_password", SqlDbType.NVarChar).Value = FormsAuthentication.HashPasswordForStoringInConfigFile(data["cu_password"].ToString(), "MD5").ToLower();
                MyCommand.CommandText = " select count(1) from companyuser where cu_user=@cu_user ";
                int count = Convert.ToInt32(MyCommand.ExecuteScalar());
                if (count == 0)
                {
                    MyCommand.CommandText = " insert into companyuser (cu_user,cu_password,cu_name,cu_trade,cu_property,cu_license,cu_area,cu_contact,cu_tel,cu_fax,cu_email,cu_url,cu_state,cu_apptime,cu_kind,cu_introduce," +
                    "cu_address,cu_hide,cu_ok,cu_base,cu_industry) values (@cu_user,@cu_password,@cu_name,@cu_trade,@cu_property,@cu_license,@cu_area,@cu_contact,@cu_tel,@cu_fax,@cu_email,@cu_url,0,getdate(),1,@cu_introduce," +
                    "@cu_address,0,@cu_ok,@cu_base,@cu_industry) ";
                    res = MyCommand.ExecuteNonQuery();
                    if (res > 0)
                        WriteLog(data["user"].ToString(), 1, data["ip"].ToString(), "用户【" + data["name"].ToString() + "】，在基地企业管理功能中进行了数据新增操作，新增记录为【用户：" + data["cu_user"] + "，单位名称：" + data["cu_name"] + "】。", MyCommand);
                    else
                        res = -1;
                }
                else
                    res = 2;
            }
            else
            {
                MyCommand.Parameters.Add("@cu_no", SqlDbType.BigInt).Value = data["cu_no"];
                MyCommand.CommandText = " select *,(select di_name from dictionary where di_type=2 and di_code=cu_property) as property1,(select di_name from dictionary where di_type=2 and di_code=@cu_property) as property2,(select di_name from dictionary where di_type=3 and di_code=cu_area) as area1,(select di_name from dictionary where di_type=3 and di_code=@cu_area) as area2,(select di_name from dictionary where di_type=1 and di_code=cu_trade) as trade1,(select di_name from dictionary where di_type=1 and di_code=@cu_trade) as trade2 from companyuser where cu_no=@cu_no ";
                DataTable dt = new DataTable();
                SqlDataAdapter da = new SqlDataAdapter(MyCommand);
                da.Fill(dt);
                if (dt != null && dt.Rows.Count > 0)
                {
                    string memo = "";
                    if (("true".Equals(data["cu_ok"]) && "0".Equals(dt.Rows[0]["cu_ok"].ToString())) || ("false".Equals(data["cu_ok"]) && "1".Equals(dt.Rows[0]["cu_ok"].ToString())))
                    {
                        string ok1 = "免审";
                        if ("0".Equals(dt.Rows[0]["cu_ok"].ToString()))
                            ok1 = "取消免审";
                        string ok2 = "免审";
                        if ("false".Equals(data["cu_ok"]))
                            ok2 = "取消免审";
                        memo = "招聘企业：" + dt.Rows[0]["cu_name"].ToString() + "，将免审从[" + ok1 + "]改为[" + ok2 + "]";
                    }
                    if (!data["cu_name"].ToString().Equals(dt.Rows[0]["cu_name"].ToString()))
                    {
                        if (string.IsNullOrEmpty(memo))
                            memo = "招聘企业：" + dt.Rows[0]["cu_name"].ToString() + "，将单位名称从[" + dt.Rows[0]["cu_name"].ToString() + "]改为[" + data["cu_name"] + "]";
                        else
                            memo += "；将单位名称从[" + dt.Rows[0]["cu_name"].ToString() + "]改为[" + data["cu_name"] + "]";
                    }
                    if (!data["cu_license"].ToString().Equals(dt.Rows[0]["cu_license"].ToString()))
                    {
                        if (string.IsNullOrEmpty(memo))
                            memo = "招聘企业：" + dt.Rows[0]["cu_name"].ToString() + "，将营业执照从[" + dt.Rows[0]["cu_license"].ToString() + "]改为[" + data["cu_license"] + "]";
                        else
                            memo += "；将营业执照从[" + dt.Rows[0]["cu_license"].ToString() + "]改为[" + data["cu_license"] + "]";
                    }
                    if (!data["cu_property"].ToString().Equals(dt.Rows[0]["cu_property"].ToString()))
                    {
                        if (string.IsNullOrEmpty(memo))
                            memo = "招聘企业：" + dt.Rows[0]["cu_name"].ToString() + "，将企业性质从[" + dt.Rows[0]["property1"].ToString() + "]改为[" + dt.Rows[0]["property2"].ToString() + "]";
                        else
                            memo += "；将企业性质从[" + dt.Rows[0]["property1"].ToString() + "]改为[" + dt.Rows[0]["property2"].ToString() + "]";
                    }
                    if (!data["cu_area"].ToString().Equals(dt.Rows[0]["cu_area"].ToString()))
                    {
                        if (string.IsNullOrEmpty(memo))
                            memo = "招聘企业：" + dt.Rows[0]["cu_name"].ToString() + "，将所在地区从[" + dt.Rows[0]["area1"].ToString() + "]改为[" + dt.Rows[0]["area2"].ToString() + "]";
                        else
                            memo += "；将所在地区从[" + dt.Rows[0]["area1"].ToString() + "]改为[" + dt.Rows[0]["area2"].ToString() + "]";
                    }
                    if (!data["cu_trade"].ToString().Equals(dt.Rows[0]["cu_trade"].ToString()))
                    {
                        if (string.IsNullOrEmpty(memo))
                            memo = "招聘企业：" + dt.Rows[0]["cu_name"].ToString() + "，将所属行业从[" + dt.Rows[0]["trade1"].ToString() + "]改为[" + dt.Rows[0]["trade2"].ToString() + "]";
                        else
                            memo += "；将所属行业从[" + dt.Rows[0]["trade1"].ToString() + "]改为[" + dt.Rows[0]["trade2"].ToString() + "]";
                    }
                    if (!data["cu_industry"].ToString().Equals(dt.Rows[0]["cu_industry"].ToString()))
                    {
                        if (string.IsNullOrEmpty(memo))
                            memo = "招聘企业：" + dt.Rows[0]["cu_name"].ToString() + "，将所属产业从[" + dt.Rows[0]["cu_industry"].ToString() + "]改为[" + dt.Rows[0]["cu_industry"].ToString() + "]";
                        else
                            memo += "；将所属产业从[" + dt.Rows[0]["cu_industry"].ToString() + "]改为[" + dt.Rows[0]["cu_industry"].ToString() + "]";
                    }
                    if (!data["cu_address"].ToString().Equals(dt.Rows[0]["cu_address"].ToString()))
                    {
                        if (string.IsNullOrEmpty(memo))
                            memo = "招聘企业：" + dt.Rows[0]["cu_name"].ToString() + "，将单位地址从[" + dt.Rows[0]["cu_address"].ToString() + "]改为[" + data["cu_address"] + "]";
                        else
                            memo += "；将单位地址从[" + dt.Rows[0]["cu_address"].ToString() + "]改为[" + data["cu_address"] + "]";
                    }
                    if (!data["cu_contact"].ToString().Equals(dt.Rows[0]["cu_contact"].ToString()))
                    {
                        if (string.IsNullOrEmpty(memo))
                            memo = "招聘企业：" + dt.Rows[0]["cu_name"].ToString() + "，将联系人从[" + dt.Rows[0]["cu_contact"].ToString() + "]改为[" + data["cu_contact"] + "]";
                        else
                            memo += "；将联系人从[" + dt.Rows[0]["cu_contact"].ToString() + "]改为[" + data["cu_contact"] + "]";
                    }
                    if (!data["cu_tel"].ToString().Equals(dt.Rows[0]["cu_tel"].ToString()))
                    {
                        if (string.IsNullOrEmpty(memo))
                            memo = "招聘企业：" + dt.Rows[0]["cu_name"].ToString() + "，将联系电话从[" + dt.Rows[0]["cu_tel"].ToString() + "]改为[" + data["cu_tel"] + "]";
                        else
                            memo += "；将联系电话从[" + dt.Rows[0]["cu_tel"].ToString() + "]改为[" + data["cu_tel"] + "]";
                    }
                    if (!data["cu_fax"].ToString().Equals(dt.Rows[0]["cu_fax"].ToString()))
                    {
                        if (string.IsNullOrEmpty(memo))
                            memo = "招聘企业：" + dt.Rows[0]["cu_name"].ToString() + "，将传真从[" + dt.Rows[0]["cu_fax"].ToString() + "]改为[" + data["cu_fax"] + "]";
                        else
                            memo += "；将传真从[" + dt.Rows[0]["cu_fax"].ToString() + "]改为[" + data["cu_fax"] + "]";
                    }
                    if (!data["cu_email"].ToString().Equals(dt.Rows[0]["cu_email"].ToString()))
                    {
                        if (string.IsNullOrEmpty(memo))
                            memo = "招聘企业：" + dt.Rows[0]["cu_name"].ToString() + "，将电子邮箱从[" + dt.Rows[0]["cu_email"].ToString() + "]改为[" + data["cu_email"] + "]";
                        else
                            memo += "；将电子邮箱从[" + dt.Rows[0]["cu_email"].ToString() + "]改为[" + data["cu_email"] + "]";
                    }
                    if (!data["cu_url"].ToString().Equals(dt.Rows[0]["cu_url"].ToString()))
                    {
                        if (string.IsNullOrEmpty(memo))
                            memo = "招聘企业：" + dt.Rows[0]["cu_name"].ToString() + "，将企业网址从[" + dt.Rows[0]["cu_url"].ToString() + "]改为[" + data["cu_url"] + "]";
                        else
                            memo += "；将企业网址从[" + dt.Rows[0]["cu_url"].ToString() + "]改为[" + data["cu_url"] + "]";
                    }
                    if (!data["cu_introduce"].ToString().Equals(dt.Rows[0]["cu_introduce"].ToString()))
                    {
                        if (string.IsNullOrEmpty(memo))
                            memo = "招聘企业：" + dt.Rows[0]["cu_name"].ToString() + "，将企业简介从[" + dt.Rows[0]["cu_introduce"].ToString() + "]改为[" + data["cu_introduce"] + "]";
                        else
                            memo += "；将企业简介从[" + dt.Rows[0]["cu_introduce"].ToString() + "]改为[" + data["cu_introduce"] + "]";
                    }
                    if (!data["cu_base"].ToString().Equals(dt.Rows[0]["cu_base"].ToString()))
                    {
                        if (string.IsNullOrEmpty(memo))
                            memo = "招聘企业：" + dt.Rows[0]["cu_name"].ToString() + "，将类型从[" + dt.Rows[0]["cu_base"].ToString() + "]改为[" + data["cu_base"] + "]";
                        else
                            memo += "；将类型从[" + dt.Rows[0]["cu_base"].ToString() + "]改为[" + data["cu_base"] + "]";
                    }
                    if (string.IsNullOrEmpty(memo))
                        memo = "招聘企业：" + dt.Rows[0]["cu_name"].ToString() + "，未修改任何字段";
                    MyCommand.CommandText = " update companyuser set cu_name=@cu_name,cu_license=@cu_license,cu_property=@cu_property,cu_area=@cu_area,cu_trade=@cu_trade,cu_address=@cu_address,cu_contact=@cu_contact,cu_tel=@cu_tel,cu_fax=@cu_fax,cu_email=@cu_email,cu_url=@cu_url,cu_introduce=@cu_introduce,cu_ok=@cu_ok,cu_industry=@cu_industry,cu_base=@cu_base,cu_modifytime=getdate(),cu_modifyip=@ip where cu_no=@cu_no ";
                    res = MyCommand.ExecuteNonQuery();
                    if (res > 0)
                        WriteLog(data["user"].ToString(), 2, data["ip"].ToString(), "用户【" + data["name"].ToString() + "】，在基地企业管理功能中进行了数据修改操作，修改记录为【" + memo + "】。", MyCommand);
                }
                else
                    res = 0;
            }
            MyTrans.Commit();
        }
        catch
        {
            MyTrans.Rollback("Tran");
            res = -1;
        }
        Close();
        return res;
    }

    /// <summary>
    /// 基地企业重置密码
    /// </summary>
    /// <param name="data"></param>
    /// <returns></returns>
    public int ResetBasePass(Hashtable data)
    {
        int res = 0;
        Open();
        SqlCommand MyCommand = MyConnection.CreateCommand();
        SqlTransaction MyTrans = MyConnection.BeginTransaction("Tran");
        MyCommand.Connection = MyConnection;
        MyCommand.Transaction = MyTrans;
        try
        {
            MyCommand.CommandText = " select * from companyuser where cu_no=@cu_no ";
            MyCommand.Parameters.Add("@cu_no", SqlDbType.BigInt).Value = data["cu_no"];
            DataTable dt = new DataTable();
            SqlDataAdapter da = new SqlDataAdapter(MyCommand);
            da.Fill(dt);
            if (dt != null && dt.Rows.Count > 0)
            {
                string memo = "重置企业：" + dt.Rows[0]["cu_name"].ToString() + "密码。";
                MyCommand.CommandText = "update companyuser set cu_password=@cu_password where cu_no=@cu_no ";
                MyCommand.Parameters.Add("@cu_password", SqlDbType.NVarChar).Value = FormsAuthentication.HashPasswordForStoringInConfigFile(data["cu_password"].ToString(), "MD5").ToLower();
                res = MyCommand.ExecuteNonQuery();
                if (res > 0)
                    WriteLog(data["user"].ToString(), 2, data["ip"].ToString(), "用户【" + data["name"].ToString() + "】，在基地企业管理功能中进行了重置企业密码操作，操作记录为【" + memo + "】。", MyCommand);
            }
            else
                res = 0;
            MyTrans.Commit();
        }
        catch (Exception ex)
        {
            MyTrans.Rollback("Tran");
            res = -1;
        }
        Close();
        return res;
    }

    /// <summary>
    /// 获取见习实习岗位
    /// </summary>
    /// <param name="is_no"></param>
    /// <returns></returns>
    public Hashtable GetIntern(string is_no)
    {
        Open();
        SqlCommand MyCommand = new SqlCommand();
        MyCommand.Connection = MyConnection;

        MyCommand.CommandText = "select * from internship where is_no =@is_no";
        MyCommand.Parameters.Add("@is_no", SqlDbType.BigInt).Value = is_no;
        DataTable data = new DataTable();
        SqlDataAdapter adapter = new SqlDataAdapter(MyCommand);
        adapter.Fill(data);
        Close();
        ArrayList da = DataTable2ArrayList(data);
        return da.Count > 0 ? (Hashtable)da[0] : null;
    }

    /// <summary>
    /// 保存见习实习岗位
    /// </summary>
    /// <param name="data"></param>
    /// <returns></returns>
    public int SaveIntern(Hashtable data)
    {
        int res;
        Open();
        SqlCommand MyCommand = MyConnection.CreateCommand();
        SqlTransaction MyTrans;
        MyTrans = MyConnection.BeginTransaction("Tran");
        MyCommand.Connection = MyConnection;
        MyCommand.Transaction = MyTrans;
        try
        {
            MyCommand.Parameters.Add("@is_cuno", SqlDbType.BigInt).Value = data["is_cuno"];
            MyCommand.Parameters.Add("@is_name", SqlDbType.NVarChar).Value = data["is_name"];
            MyCommand.Parameters.Add("@is_num", SqlDbType.Int).Value = data["is_num"];
            MyCommand.Parameters.Add("@is_sex", SqlDbType.NVarChar).Value = data["is_sex"];
            MyCommand.Parameters.Add("@is_kind", SqlDbType.NVarChar).Value = data["is_kind"];
            MyCommand.Parameters.Add("@is_target", SqlDbType.NVarChar).Value = data["is_target"];
            MyCommand.Parameters.Add("@is_edu", SqlDbType.NVarChar).Value = data["is_edu"];
            MyCommand.Parameters.Add("@is_edu2", SqlDbType.NVarChar).Value = data["is_edu2"].ToString() == "true" ? "以上" : "";
            MyCommand.Parameters.Add("@is_jobtype1", SqlDbType.NVarChar).Value = data["is_jobtype1"];
            MyCommand.Parameters.Add("@is_jobtype2", SqlDbType.NVarChar).Value = data["is_jobtype2"];
            MyCommand.Parameters.Add("@is_jobtype11", SqlDbType.NVarChar).Value = data["is_jobtype11"];
            MyCommand.Parameters.Add("@is_jobtype22", SqlDbType.NVarChar).Value = data["is_jobtype22"];
            MyCommand.Parameters.Add("@is_age", SqlDbType.NVarChar).Value = data["is_age"];
            MyCommand.Parameters.Add("@is_pay", SqlDbType.NVarChar).Value = data["is_pay"];
            MyCommand.Parameters.Add("@is_area", SqlDbType.NVarChar).Value = data["is_area"];
            MyCommand.Parameters.Add("@is_memo", SqlDbType.NText).Value = data["is_memo"];
            MyCommand.Parameters.Add("@is_effect", SqlDbType.Int).Value = data["is_effect"];
            MyCommand.Parameters.Add("@user", SqlDbType.NVarChar).Value = data["user"];
            MyCommand.Parameters.Add("@ip", SqlDbType.NVarChar).Value = data["ip"];

            if (string.IsNullOrEmpty(data["is_no"].ToString()))
            {
                MyCommand.CommandText = "insert into internship (is_cuno,is_name,is_num,is_sex,is_kind,is_edu,is_edu2,is_target,is_jobtype1,is_jobtype11,is_jobtype2,is_jobtype22,is_age,is_pay,is_area,is_effect,is_memo," +
                    "is_inserttime,is_insertip,is_modifytime,is_modifyip,is_hits,is_resumenum,is_hide,is_delete,is_state,is_orderid) values (@is_cuno,@is_name,@is_num,@is_sex,@is_kind,@is_edu,@is_edu2,@is_target,@is_jobtype1,@is_jobtype11,@is_jobtype2,@is_jobtype22,@is_age,@is_pay,@is_area,@is_effect,@is_memo,getDate(),@ip,getDate(),@ip,0,0,0,0,1,0) ";
                res = MyCommand.ExecuteNonQuery();
                if (res > 0)
                    WriteLog(data["user"].ToString(), 1, data["ip"].ToString(), "用户【" + data["name"].ToString() + "】，在见习实习岗位管理功能中进行了见习实习岗位新增操作，新增记录为【企业名称：" + data["cu_name"] + "，见习实习岗位：" + data["is_name"] + "】。", MyCommand);
                else
                    res = -1;
            }
            else
            {
                MyCommand.CommandText = " select *,(select di_name from dictionary where di_type=5 and di_code=is_sex) as sex1,(select di_name from dictionary where di_type=5 and di_code=@is_sex) as sex2,(select di_name from dictionary where di_type=6 and di_code=is_kind) as kind1,(select di_name from dictionary where di_type=6 and di_code=@is_kind) as kind2,(select di_name from dictionary where di_type=4 and di_code=is_edu) as edu1,(select di_name from dictionary where di_type=4 and di_code=@is_edu) as edu2," +
                    "(select jt_name from jobtype where jt_id=is_jobtype1) as jobtype11,(select jt_name from jobtype where jt_id=@is_jobtype1) as jobtype12,(select jt_name from jobtype where jt_id=is_jobtype2) as jobtype21,(select jt_name from jobtype where jt_id=@is_jobtype2) as jobtype22,(select di_name from dictionary where di_type=3 and di_code=is_area) as area1," +
                    "(select di_name from dictionary where di_type=3 and di_code=@is_area) as area2,(select jt_name from jobtype where jt_id=is_jobtype11) as jobtype31,(select jt_name from jobtype where jt_id=@is_jobtype11) as jobtype32,(select jt_name from jobtype where jt_id=is_jobtype22) as jobtype41,(select jt_name from jobtype where jt_id=@is_jobtype22) as jobtype42 from internship where is_no=@is_no ";
                MyCommand.Parameters.Add("@is_no", SqlDbType.BigInt).Value = data["is_no"];
                DataTable dt = new DataTable();
                SqlDataAdapter da = new SqlDataAdapter(MyCommand);
                da.Fill(dt);
                if (dt != null && dt.Rows.Count > 0)
                {
                    string memo = "";
                    if (!data["is_name"].ToString().Equals(dt.Rows[0]["is_name"].ToString()))
                        memo = "见习实习岗位：" + dt.Rows[0]["is_name"].ToString() + "，将岗位名称从[" + dt.Rows[0]["is_name"].ToString() + "]改为[" + data["is_name"] + "]";
                    if (!data["is_num"].ToString().Equals(dt.Rows[0]["is_num"].ToString()))
                    {
                        if (string.IsNullOrEmpty(memo))
                            memo = "见习实习岗位：" + dt.Rows[0]["is_name"].ToString() + "，将招聘人数从[" + dt.Rows[0]["is_num"].ToString() + "]改为[" + data["is_num"] + "]";
                        else
                            memo += "；将招聘人数从[" + dt.Rows[0]["is_num"].ToString() + "]改为[" + data["is_num"] + "]";
                    }
                    if (!data["is_sex"].ToString().Equals(dt.Rows[0]["is_sex"].ToString()))
                    {
                        if (string.IsNullOrEmpty(memo))
                            memo = "见习实习岗位：" + dt.Rows[0]["is_name"].ToString() + "，将性别从[" + dt.Rows[0]["sex1"].ToString() + "]改为[" + dt.Rows[0]["sex2"].ToString() + "]";
                        else
                            memo += "；将性别从[" + dt.Rows[0]["sex1"].ToString() + "]改为[" + dt.Rows[0]["sex2"].ToString() + "]";
                    }
                    if (!data["is_kind"].ToString().Equals(dt.Rows[0]["is_kind"].ToString()))
                    {
                        if (string.IsNullOrEmpty(memo))
                            memo = "见习实习岗位：" + dt.Rows[0]["is_name"].ToString() + "，将工作性质从[" + dt.Rows[0]["kind1"].ToString() + "]改为[" + dt.Rows[0]["kind2"].ToString() + "]";
                        else
                            memo += "；将工作性质从[" + dt.Rows[0]["kind1"].ToString() + "]改为[" + dt.Rows[0]["kind2"].ToString() + "]";
                    }
                    if (!data["is_edu"].ToString().Equals(dt.Rows[0]["is_edu"].ToString()))
                    {
                        if (string.IsNullOrEmpty(memo))
                            memo = "见习实习岗位：" + dt.Rows[0]["is_name"].ToString() + "，将学历从[" + dt.Rows[0]["edu1"].ToString() + "]改为[" + dt.Rows[0]["edu2"].ToString() + "]";
                        else
                            memo += "；将学历从[" + dt.Rows[0]["edu1"].ToString() + "]改为[" + dt.Rows[0]["edu2"].ToString() + "]";
                    }
                    if (("true".Equals(data["is_edu2"]) && string.IsNullOrEmpty(dt.Rows[0]["is_edu2"].ToString())) || ("false".Equals(data["is_edu2"]) && !string.IsNullOrEmpty(dt.Rows[0]["is_edu2"].ToString())))
                    {
                        string s1 = "以上";
                        if ("".Equals(dt.Rows[0]["is_edu2"].ToString()))
                            s1 = "";
                        string s2 = "以上";
                        if (("false".Equals(data["is_edu2"])))
                            s2 = "";
                        if (string.IsNullOrEmpty(memo))
                            memo = "见习实习岗位：" + dt.Rows[0]["is_name"].ToString() + "，将学历2从[" + s1 + "]改为[" + s2 + "]";
                        else
                            memo += "；将学历2从[" + s1 + "]改为[" + s2 + "]";
                    }
                    if (!data["is_target"].ToString().Equals(dt.Rows[0]["is_target"].ToString()))
                    {
                        if (string.IsNullOrEmpty(memo))
                            memo = "见习实习岗位：" + dt.Rows[0]["is_name"].ToString() + "，将缴纳保险从[" + dt.Rows[0]["is_target"].ToString() + "]改为[" + dt.Rows[0]["is_target"].ToString() + "]";
                        else
                            memo += "；将缴纳保险从[" + dt.Rows[0]["is_target"].ToString() + "]改为[" + dt.Rows[0]["is_target"].ToString() + "]";
                    }
                    if (!data["is_jobtype1"].ToString().Equals(dt.Rows[0]["is_jobtype1"].ToString()))
                    {
                        if (string.IsNullOrEmpty(memo))
                            memo = "见习实习岗位：" + dt.Rows[0]["is_name"].ToString() + "，将岗位类别1从[" + dt.Rows[0]["jobtype11"].ToString() + "]改为[" + dt.Rows[0]["jobtype12"].ToString() + "]";
                        else
                            memo += "；将岗位类别1从[" + dt.Rows[0]["jobtype11"].ToString() + "]改为[" + dt.Rows[0]["jobtype12"].ToString() + "]";
                    }
                    if (!data["is_jobtype11"].ToString().Equals(dt.Rows[0]["is_jobtype11"].ToString()))
                    {
                        if (string.IsNullOrEmpty(memo))
                            memo = "见习实习岗位：" + dt.Rows[0]["is_name"].ToString() + "，将岗位类别11从[" + dt.Rows[0]["jobtype31"].ToString() + "]改为[" + dt.Rows[0]["jobtype32"].ToString() + "]";
                        else
                            memo += "；将岗位类别11从[" + dt.Rows[0]["jobtype31"].ToString() + "]改为[" + dt.Rows[0]["jobtype32"].ToString() + "]";
                    }
                    if (!data["is_jobtype2"].ToString().Equals(dt.Rows[0]["is_jobtype2"].ToString()))
                    {
                        if (string.IsNullOrEmpty(memo))
                            memo = "见习实习岗位：" + dt.Rows[0]["is_name"].ToString() + "，将岗位类别2从[" + dt.Rows[0]["jobtype21"].ToString() + "]改为[" + dt.Rows[0]["jobtype22"].ToString() + "]";
                        else
                            memo += "；将岗位类别2从[" + dt.Rows[0]["jobtype21"].ToString() + "]改为[" + dt.Rows[0]["jobtype22"].ToString() + "]";
                    }
                    if (!data["is_jobtype22"].ToString().Equals(dt.Rows[0]["is_jobtype22"].ToString()))
                    {
                        if (string.IsNullOrEmpty(memo))
                            memo = "见习实习岗位：" + dt.Rows[0]["is_name"].ToString() + "，将岗位类别22从[" + dt.Rows[0]["jobtype41"].ToString() + "]改为[" + dt.Rows[0]["jobtype42"].ToString() + "]";
                        else
                            memo += "；将岗位类别22从[" + dt.Rows[0]["jobtype41"].ToString() + "]改为[" + dt.Rows[0]["jobtype42"].ToString() + "]";
                    }
                    if (!data["is_age"].ToString().Equals(dt.Rows[0]["is_age"].ToString()))
                    {
                        if (string.IsNullOrEmpty(memo))
                            memo = "见习实习岗位：" + dt.Rows[0]["is_name"].ToString() + "，将年龄从[" + dt.Rows[0]["is_age"].ToString() + "]改为[" + data["is_age"] + "]";
                        else
                            memo += "；将年龄从[" + dt.Rows[0]["is_age"].ToString() + "]改为[" + data["is_age"] + "]";
                    }
                    if (!data["is_pay"].ToString().Equals(dt.Rows[0]["is_pay"].ToString()))
                    {
                        if (string.IsNullOrEmpty(memo))
                            memo = "见习实习岗位：" + dt.Rows[0]["is_name"].ToString() + "，将待遇从[" + dt.Rows[0]["is_pay"].ToString() + "]改为[" + data["is_pay"] + "]";
                        else
                            memo += "；将待遇从[" + dt.Rows[0]["is_pay"].ToString() + "]改为[" + data["is_pay"] + "]";
                    }
                    if (!data["is_area"].ToString().Equals(dt.Rows[0]["is_area"].ToString()))
                    {
                        if (string.IsNullOrEmpty(memo))
                            memo = "见习实习岗位：" + dt.Rows[0]["is_name"].ToString() + "，将工作地区从[" + dt.Rows[0]["area1"].ToString() + "]改为[" + dt.Rows[0]["area2"].ToString() + "]";
                        else
                            memo += "；将工作地区从[" + dt.Rows[0]["area1"].ToString() + "]改为[" + dt.Rows[0]["area2"].ToString() + "]";
                    }
                    if (!data["is_effect"].ToString().Equals(dt.Rows[0]["is_effect"].ToString()))
                    {
                        if (string.IsNullOrEmpty(memo))
                            memo = "见习实习岗位：" + dt.Rows[0]["is_name"].ToString() + "，将有效期从[" + dt.Rows[0]["is_effect"].ToString() + "]改为[" + data["is_effect"] + "]";
                        else
                            memo += "；将有效期从[" + dt.Rows[0]["is_effect"].ToString() + "]改为[" + data["is_effect"] + "]";
                    }
                    if (!data["is_memo"].ToString().Equals(dt.Rows[0]["is_memo"].ToString()))
                    {
                        if (string.IsNullOrEmpty(memo))
                            memo = "见习实习岗位：" + dt.Rows[0]["is_name"].ToString() + "，将其他要求从[" + dt.Rows[0]["is_memo"].ToString() + "]改为[" + data["is_memo"] + "]";
                        else
                            memo += "；将其他要求从[" + dt.Rows[0]["is_memo"].ToString() + "]改为[" + data["is_memo"] + "]";
                    }
                    if (string.IsNullOrEmpty(memo))
                        memo = "见习实习岗位：" + dt.Rows[0]["is_name"].ToString() + "，未修改任何字段";
                    MyCommand.CommandText = " update internship set is_name=@is_name,is_num=@is_num,is_sex=@is_sex,is_kind=@is_kind,is_edu=@is_edu,is_edu2=@is_edu2,is_target=@is_target,is_jobtype1=@is_jobtype1,is_jobtype11=@is_jobtype11,is_jobtype2=@is_jobtype2,is_jobtype22=@is_jobtype22,is_age=@is_age,is_pay=@is_pay,is_area=@is_area,is_effect=@is_effect,is_memo=@is_memo,is_modifytime=getdate() where is_no=@is_no ";
                    res = MyCommand.ExecuteNonQuery();
                    if (res > 0)
                        WriteLog(data["user"].ToString(), 2, data["ip"].ToString(), "用户【" + data["name"].ToString() + "】，在见习实习岗位管理功能中进行了见习实习岗位修改操作，修改记录为【" + memo + "】。", MyCommand);
                }
                else
                    res = 0;
            }
            MyTrans.Commit();
        }
        catch
        {
            MyTrans.Rollback("Tran");
            res = -1;
        }
        Close();
        return res;
    }

    /// <summary>
    /// 删除见习实习岗位
    /// </summary>
    /// <param name="uid"></param>
    /// <param name="name"></param>
    /// <param name="ip"></param>
    /// <param name="is_no"></param>
    /// <returns></returns>
    public int DeleteIntern(string uid, string name, string ip, string is_no)
    {
        int res = 0;
        Open();
        SqlCommand MyCommand = MyConnection.CreateCommand();
        SqlTransaction MyTrans = MyConnection.BeginTransaction("Tran");
        MyCommand.Connection = MyConnection;
        MyCommand.Transaction = MyTrans;
        try
        {
            string[] id = is_no.Split(',');
            for (int i = 0; i < id.Length; i++)
            {
                MyCommand.CommandText = " select * from internship where is_no=@is_no ";
                MyCommand.Parameters.Add("@is_no", SqlDbType.BigInt).Value = id[i];
                DataTable dt = new DataTable();
                SqlDataAdapter da = new SqlDataAdapter(MyCommand);
                da.Fill(dt);
                if (dt != null && dt.Rows.Count > 0)
                {
                    string memo = "见习实习岗位：" + dt.Rows[0]["is_name"].ToString();
                    MyCommand.CommandText = "delete from internship where is_no=@is_no ";
                    res = MyCommand.ExecuteNonQuery();
                    if (res > 0)
                        WriteLog(uid, 3, ip, "用户【" + name + "】，在见习实习岗位管理功能中进行了见习实习岗位删除操作，删除记录为【" + memo + "】。", MyCommand);
                }
                MyCommand.Parameters.Clear();
            }
            MyTrans.Commit();
            res = 1;
        }
        catch (Exception ex)
        {
            MyTrans.Rollback("Tran");
            res = -1;
        }
        Close();
        return res;
    }

    /// <summary>
    /// 审核见习实习岗位
    /// </summary>
    /// <param name="uid"></param>
    /// <param name="name"></param>
    /// <param name="ip"></param>
    /// <param name="is_no"></param>
    /// <param name="is_state"></param>
    /// <returns></returns>
    public int CheckIntern(string uid, string name, string ip, string is_no, string is_state)
    {
        int res = 0;
        Open();
        SqlCommand MyCommand = MyConnection.CreateCommand();
        SqlTransaction MyTrans = MyConnection.BeginTransaction("Tran");
        MyCommand.Connection = MyConnection;
        MyCommand.Transaction = MyTrans;
        try
        {
            string[] id = is_no.Split(',');
            for (int i = 0; i < id.Length; i++)
            {
                MyCommand.CommandText = " select * from internship where is_no=@is_no ";
                MyCommand.Parameters.Add("@is_no", SqlDbType.BigInt).Value = id[i];
                DataTable dt = new DataTable();
                SqlDataAdapter da = new SqlDataAdapter(MyCommand);
                da.Fill(dt);
                if (dt != null && dt.Rows.Count > 0)
                {
                    string memo = "";
                    if (!is_state.Equals(dt.Rows[0]["is_state"].ToString()))
                    {
                        string s1 = "未审核";
                        if ("1".Equals(dt.Rows[0]["is_state"].ToString()))
                            s1 = "审核通过";
                        else if ("2".Equals(dt.Rows[0]["is_state"].ToString()))
                            s1 = "审核未通过";
                        string s2 = "未审核";
                        if ("1".Equals(is_state))
                            s2 = "审核通过";
                        else if ("2".Equals(is_state))
                            s2 = "审核未通过";
                        memo = "招聘岗位：" + dt.Rows[0]["is_name"].ToString() + "，将状态从[" + s1 + "]改为[" + s2 + "]";
                    }
                    if (string.IsNullOrEmpty(memo))
                        memo = "见习实习岗位：" + dt.Rows[0]["is_name"].ToString() + "，未修改任何字段";
                    MyCommand.CommandText = "update internship set is_state=@is_state where is_no=@is_no ";
                    MyCommand.Parameters.Add("@is_state", SqlDbType.Int).Value = is_state;
                    res = MyCommand.ExecuteNonQuery();
                    if (res > 0)
                        WriteLog(uid, 2, ip, "用户【" + name + "】，在见习实习岗位管理功能中进行了数据修改操作，修改记录为【" + memo + "】。", MyCommand);
                }
                MyCommand.Parameters.Clear();
            }
            MyTrans.Commit();
            res = 1;
        }
        catch (Exception ex)
        {
            MyTrans.Rollback("Tran");
            res = -1;
        }
        Close();
        return res;
    }

    /// <summary>
    /// 隐藏/显示见习实习岗位
    /// </summary>
    /// <param name="uid"></param>
    /// <param name="name"></param>
    /// <param name="ip"></param>
    /// <param name="is_no"></param>
    /// <param name="is_hide"></param>
    /// <returns></returns>
    public int LockIntern(string uid, string name, string ip, string is_no, string is_hide)
    {
        int res = 0;
        Open();
        SqlCommand MyCommand = MyConnection.CreateCommand();
        SqlTransaction MyTrans = MyConnection.BeginTransaction("Tran");
        MyCommand.Connection = MyConnection;
        MyCommand.Transaction = MyTrans;
        try
        {
            string[] id = is_no.Split(',');
            for (int i = 0; i < id.Length; i++)
            {
                MyCommand.CommandText = " select * from internship where is_no=@is_no ";
                MyCommand.Parameters.Add("@is_no", SqlDbType.BigInt).Value = id[i];
                DataTable dt = new DataTable();
                SqlDataAdapter da = new SqlDataAdapter(MyCommand);
                da.Fill(dt);
                if (dt != null && dt.Rows.Count > 0)
                {
                    string memo = "";
                    if (!is_hide.Equals(dt.Rows[0]["is_hide"].ToString()))
                    {
                        string s1 = "隐藏";
                        if (ConfigurationManager.AppSettings["Open"].Equals(dt.Rows[0]["is_hide"].ToString()))
                            s1 = "显示";
                        string s2 = "隐藏";
                        if (ConfigurationManager.AppSettings["Open"].Equals(is_hide))
                            s2 = "显示";
                        memo = "见习实习岗位：" + dt.Rows[0]["is_name"].ToString() + "，将状态从[" + s1 + "]改为[" + s2 + "]";
                    }
                    if (string.IsNullOrEmpty(memo))
                        memo = "见习实习岗位：" + dt.Rows[0]["is_name"].ToString() + "，未修改任何字段";
                    MyCommand.CommandText = "update internship set is_hide=@is_hide where is_no=@is_no ";
                    MyCommand.Parameters.Add("@is_hide", SqlDbType.Int).Value = is_hide;
                    res = MyCommand.ExecuteNonQuery();
                    if (res > 0)
                        WriteLog(uid, 2, ip, "用户【" + name + "】，在见习实习岗位管理功能中进行了见习实习岗位修改操作，修改记录为【" + memo + "】。", MyCommand);
                }
                MyCommand.Parameters.Clear();
            }
            MyTrans.Commit();
            res = 1;
        }
        catch (Exception ex)
        {
            MyTrans.Rollback("Tran");
            res = -1;
        }
        Close();
        return res;
    }

    /// <summary>
    /// 归零见习实习岗位点击率
    /// </summary>
    /// <param name="uid"></param>
    /// <param name="name"></param>
    /// <param name="ip"></param>
    /// <param name="is_no"></param>
    /// <returns></returns>
    public int ZeroIntern(string uid, string name, string ip, string is_no)
    {
        int res = 0;
        Open();
        SqlCommand MyCommand = MyConnection.CreateCommand();
        SqlTransaction MyTrans = MyConnection.BeginTransaction("Tran");
        MyCommand.Connection = MyConnection;
        MyCommand.Transaction = MyTrans;
        try
        {
            string[] id = is_no.Split(',');
            for (int i = 0; i < id.Length; i++)
            {
                MyCommand.CommandText = " select * from internship where is_no=@is_no ";
                MyCommand.Parameters.Add("@is_no", SqlDbType.BigInt).Value = id[i];
                DataTable dt = new DataTable();
                SqlDataAdapter da = new SqlDataAdapter(MyCommand);
                da.Fill(dt);
                if (dt != null && dt.Rows.Count > 0)
                {
                    string memo = "";
                    if (string.IsNullOrEmpty(memo))
                        memo = "见习实习岗位：" + dt.Rows[0]["is_name"].ToString() + "，将点击率归零";
                    MyCommand.CommandText = "update internship set is_hits=0 where is_no=@is_no ";
                    res = MyCommand.ExecuteNonQuery();
                    if (res > 0)
                        WriteLog(uid, 2, ip, "用户【" + name + "】，在见习实习岗位管理功能中进行了见习实习岗位修改操作，修改记录为【" + memo + "】。", MyCommand);
                }
                MyCommand.Parameters.Clear();
            }
            MyTrans.Commit();
            res = 1;
        }
        catch (Exception ex)
        {
            MyTrans.Rollback("Tran");
            res = -1;
        }
        Close();
        return res;
    }

    /// <summary>
    /// 刷新见习实习岗位
    /// </summary>
    /// <param name="uid"></param>
    /// <param name="name"></param>
    /// <param name="ip"></param>
    /// <param name="is_no"></param>
    /// <returns></returns>
    public int RefreshIntern(string uid, string name, string ip, string is_no)
    {
        int res = 0;
        Open();
        SqlCommand MyCommand = MyConnection.CreateCommand();
        SqlTransaction MyTrans = MyConnection.BeginTransaction("Tran");
        MyCommand.Connection = MyConnection;
        MyCommand.Transaction = MyTrans;
        try
        {
            string[] id = is_no.Split(',');
            for (int i = 0; i < id.Length; i++)
            {
                MyCommand.CommandText = " select * from internship where is_no=@is_no ";
                MyCommand.Parameters.Add("@is_no", SqlDbType.BigInt).Value = id[i];
                DataTable dt = new DataTable();
                SqlDataAdapter da = new SqlDataAdapter(MyCommand);
                da.Fill(dt);
                if (dt != null && dt.Rows.Count > 0)
                {
                    string memo = "";
                    if (string.IsNullOrEmpty(memo))
                        memo = "见习实习岗位：" + dt.Rows[0]["is_name"].ToString() + "，将状态进行刷新";
                    MyCommand.CommandText = "update internship set is_modifytime=getdate(),is_modifyip=@is_modifyip where is_no=@is_no ";
                    MyCommand.Parameters.Add("@is_modifyip", SqlDbType.NVarChar).Value = ip;
                    res = MyCommand.ExecuteNonQuery();
                    if (res > 0)
                    {
                        MyCommand.CommandText = "insert into internrefresh (ir_reno,ir_refreshtime,ir_refreship) values (@is_no,getDate(),@is_modifyip) ";
                        MyCommand.ExecuteNonQuery();
                        WriteLog(uid, 2, ip, "用户【" + name + "】，在见习实习岗位管理功能中进行了见习实习岗位修改操作，修改记录为【" + memo + "】。", MyCommand);
                    }
                }
                MyCommand.Parameters.Clear();
            }
            MyTrans.Commit();
            res = 1;
        }
        catch (Exception ex)
        {
            MyTrans.Rollback("Tran");
            res = -1;
        }
        Close();
        return res;
    }

    public Hashtable GetVideo(string uv_no)
    {
        Open();
        SqlCommand MyCommand = new SqlCommand();
        MyCommand.Connection = MyConnection;

        MyCommand.CommandText = "select * from UploadVideo where uv_no =@uv_no";
        MyCommand.Parameters.Add("@uv_no", SqlDbType.BigInt).Value = uv_no;
        DataTable data = new DataTable();
        SqlDataAdapter adapter = new SqlDataAdapter(MyCommand);
        adapter.Fill(data);
        Close();
        ArrayList da = DataTable2ArrayList(data);
        return da.Count > 0 ? (Hashtable)da[0] : null;
    }

    /// <summary>
    /// 保存视频
    /// </summary>
    /// <param name="data"></param>
    /// <returns></returns>
    public int SaveVideo(Hashtable data)
    {
        int res;
        Open();
        SqlCommand MyCommand = MyConnection.CreateCommand();
        SqlTransaction MyTrans;
        MyTrans = MyConnection.BeginTransaction("Tran");
        MyCommand.Connection = MyConnection;
        MyCommand.Transaction = MyTrans;
        try
        {
            MyCommand.Parameters.Add("@uv_title", SqlDbType.NVarChar).Value = data["uv_title"];
            if (data["uv_img"] == null || string.IsNullOrEmpty(data["uv_img"].ToString()))
                data["uv_img"] = "";
            MyCommand.Parameters.Add("@uv_img", SqlDbType.NVarChar).Value = data["uv_img"];
            MyCommand.Parameters.Add("@uv_video", SqlDbType.NVarChar).Value = data["uv_video"];
            MyCommand.Parameters.Add("@user", SqlDbType.NVarChar).Value = data["user"];
            MyCommand.Parameters.Add("@ip", SqlDbType.NVarChar).Value = data["ip"];

            if (string.IsNullOrEmpty(data["uv_no"].ToString()))
            {
                MyCommand.CommandText = "insert into UploadVideo (uv_title,uv_img,uv_video,uv_hits,uv_hide,uv_inserttime,uv_insertuser,uv_insertip,uv_modifytime,uv_imodifyuser,uv_modifyip) values (@uv_title,@uv_img,@uv_video,0,0,getdate(),@user,@ip,getdate(),@user,@ip) ";
                res = MyCommand.ExecuteNonQuery();
                if (res > 0)
                    WriteLog(data["user"].ToString(), 1, data["ip"].ToString(), "用户【" + data["name"].ToString() + "】，在上传视频管理功能中进行了视频新增操作，新增记录为【企业名称：" + data["uv_title"] + "】。", MyCommand);
                else
                    res = -1;
            }
            else
            {
                MyCommand.CommandText = " select * from UploadVideo where uv_no=@uv_no ";
                MyCommand.Parameters.Add("@uv_no", SqlDbType.BigInt).Value = data["uv_no"];
                DataTable dt = new DataTable();
                SqlDataAdapter da = new SqlDataAdapter(MyCommand);
                da.Fill(dt);
                if (dt != null && dt.Rows.Count > 0)
                {
                    string memo = "";
                    string name = "企业视频：" + dt.Rows[0]["uv_title"].ToString();
                    if (!data["uv_title"].ToString().Equals(dt.Rows[0]["uv_title"].ToString()))
                        memo = name + "，将企业名称从[" + dt.Rows[0]["uv_title"].ToString() + "]改为[" + data["is_name"] + "]";
                    if (!data["uv_img"].ToString().Equals(dt.Rows[0]["uv_img"].ToString()))
                    {
                        if (string.IsNullOrEmpty(memo))
                            memo = name + "，将图片从[" + dt.Rows[0]["uv_img"].ToString() + "]改为[" + data["uv_img"] + "]";
                        else
                            memo += "；将图片从[" + dt.Rows[0]["uv_img"].ToString() + "]改为[" + data["uv_img"] + "]";
                    }
                    if (!data["uv_video"].ToString().Equals(dt.Rows[0]["uv_video"].ToString()))
                    {
                        if (string.IsNullOrEmpty(memo))
                            memo = name + "，将视频从[" + dt.Rows[0]["uv_video"].ToString() + "]改为[" + dt.Rows[0]["uv_video"].ToString() + "]";
                        else
                            memo += "；将视频从[" + dt.Rows[0]["uv_video"].ToString() + "]改为[" + dt.Rows[0]["uv_video"].ToString() + "]";
                    }
                    if (string.IsNullOrEmpty(memo))
                        memo = "企业视频：" + dt.Rows[0]["uv_title"].ToString() + "，未修改任何字段";
                    MyCommand.CommandText = " update UploadVideo set uv_title=@uv_title,uv_img=@uv_img,uv_video=@uv_video,uv_imodifyuser=@user,uv_modifytime=getdate(),uv_modifyip=@ip where uv_no=@uv_no ";
                    res = MyCommand.ExecuteNonQuery();
                    if (res > 0)
                        WriteLog(data["user"].ToString(), 2, data["ip"].ToString(), "用户【" + data["name"].ToString() + "】，在上传视频管理功能中进行了修改操作，修改记录为【" + memo + "】。", MyCommand);
                }
                else
                    res = 0;
            }
            MyTrans.Commit();
        }
        catch
        {
            MyTrans.Rollback("Tran");
            res = -1;
        }
        Close();
        return res;
    }

    /// <summary>
    /// 显示、隐藏视频
    /// </summary>
    /// <param name="uid"></param>
    /// <param name="name"></param>
    /// <param name="ip"></param>
    /// <param name="uv_no"></param>
    /// <param name="uv_hide"></param>
    /// <returns></returns>
    public int LockVideo(string uid, string name, string ip, string uv_no, string uv_hide)
    {
        int res = 0;
        Open();
        SqlCommand MyCommand = MyConnection.CreateCommand();
        SqlTransaction MyTrans = MyConnection.BeginTransaction("Tran");
        MyCommand.Connection = MyConnection;
        MyCommand.Transaction = MyTrans;
        try
        {
            string[] id = uv_no.Split(',');
            for (int i = 0; i < id.Length; i++)
            {
                MyCommand.CommandText = " select * from UploadVideo where uv_no=@uv_no ";
                MyCommand.Parameters.Add("@uv_no", SqlDbType.BigInt).Value = id[i];
                DataTable dt = new DataTable();
                SqlDataAdapter da = new SqlDataAdapter(MyCommand);
                da.Fill(dt);
                if (dt != null && dt.Rows.Count > 0)
                {
                    string memo = "";
                    if (!uv_hide.Equals(dt.Rows[0]["uv_hide"].ToString()))
                    {
                        string s1 = "隐藏";
                        if (ConfigurationManager.AppSettings["Open"].Equals(dt.Rows[0]["uv_hide"].ToString()))
                            s1 = "显示";
                        string s2 = "隐藏";
                        if (ConfigurationManager.AppSettings["Open"].Equals(uv_hide))
                            s2 = "显示";
                        memo = "视频企业：" + dt.Rows[0]["uv_title"].ToString() + "，将状态从[" + s1 + "]改为[" + s2 + "]";
                    }
                    if (string.IsNullOrEmpty(memo))
                        memo = "视频企业：" + dt.Rows[0]["uv_title"].ToString() + "，未修改任何字段";
                    MyCommand.CommandText = "update UploadVideo set uv_hide=@uv_hide where uv_no=@uv_no ";
                    MyCommand.Parameters.Add("@uv_hide", SqlDbType.Int).Value = uv_hide;
                    res = MyCommand.ExecuteNonQuery();
                    if (res > 0)
                        WriteLog(uid, 2, ip, "用户【" + name + "】，在上传视频管理功能中进行了视频修改操作，修改记录为【" + memo + "】。", MyCommand);
                }
                MyCommand.Parameters.Clear();
            }
            MyTrans.Commit();
            res = 1;
        }
        catch (Exception ex)
        {
            MyTrans.Rollback("Tran");
            res = -1;
        }
        Close();
        return res;
    }

    /// <summary>
    /// 删除视频
    /// </summary>
    /// <param name="uid"></param>
    /// <param name="name"></param>
    /// <param name="ip"></param>
    /// <param name="uv_no"></param>
    /// <returns></returns>
    public int DeleteVideo(string uid, string name, string ip, string uv_no)
    {
        int res = 0;
        Open();
        SqlCommand MyCommand = MyConnection.CreateCommand();
        SqlTransaction MyTrans = MyConnection.BeginTransaction("Tran");
        MyCommand.Connection = MyConnection;
        MyCommand.Transaction = MyTrans;
        try
        {
            string[] id = uv_no.Split(',');
            for (int i = 0; i < id.Length; i++)
            {
                MyCommand.CommandText = " select * from UploadVideo where uv_no=@uv_no ";
                MyCommand.Parameters.Add("@uv_no", SqlDbType.BigInt).Value = id[i];
                DataTable dt = new DataTable();
                SqlDataAdapter da = new SqlDataAdapter(MyCommand);
                da.Fill(dt);
                if (dt != null && dt.Rows.Count > 0)
                {
                    string memo = "视频企业：" + dt.Rows[0]["uv_title"].ToString();
                    MyCommand.CommandText = "delete from UploadVideo where uv_no=@uv_no ";
                    res = MyCommand.ExecuteNonQuery();
                    if (res > 0)
                        WriteLog(uid, 3, ip, "用户【" + name + "】，在上传视频管理功能中进行了视频删除操作，删除记录为【" + memo + "】。", MyCommand);
                }
                MyCommand.Parameters.Clear();
            }
            MyTrans.Commit();
            res = 1;
        }
        catch (Exception ex)
        {
            MyTrans.Rollback("Tran");
            res = -1;
        }
        Close();
        return res;
    }

    public DataTable GetVideoList()
    {
        Open();
        SqlCommand MyCommand = new SqlCommand();
        MyCommand.Connection = MyConnection;
        MyCommand.CommandText = "select * from UploadVideo where uv_hide=0 order by uv_modifytime desc";
        DataTable data = new DataTable();
        SqlDataAdapter adapter = new SqlDataAdapter(MyCommand);
        adapter.Fill(data);
        Close();
        return data;
    }
    //获取企业信息 sc_delete标记 0为正常 1为三方企业已经删除
    public DataTable searchCompanysFromHzhr(string key)
    {
        Open();
        SqlCommand myCommand = new SqlCommand();
        myCommand.Connection = MyConnection;
        if(!string.IsNullOrEmpty(key)){
        myCommand.CommandText = @"select cu_no,cu_name,cu_address,cu_introduce,cu_trade,cu_property,
cu_area,cu_postcode,cu_contact,cu_tel,cu_fax,cu_email,cu_url from companyuser where cu_no not in 
(select sc_company_id from f_company_synccompanys where sc_delete <> 1) and cu_name like '%"+key+"%' order by cu_no desc";
            }else{
            myCommand.CommandText = @"select cu_no,cu_name,cu_address,cu_introduce,cu_trade,cu_property,
cu_area,cu_postcode,cu_contact,cu_tel,cu_fax,cu_email,cu_url from companyuser where cu_no not in 
(select sc_company_id from f_company_synccompanys where sc_delete <> 1) order by cu_no desc";
        }
        DataTable data = new DataTable();
        SqlDataAdapter adapter = new SqlDataAdapter(myCommand);
        adapter.Fill(data);
        Close();
        return data;
    }
    //获取需要同步的杭州天正雅思企业信息
    public DataTable searchCompanysFromTzys(string key)
    {
        String strConn = ConfigurationManager.AppSettings["TzysMySqlConnectionString"];
        MySqlConnection connection = new MySqlConnection(strConn);
        connection.Open();
        MySqlCommand myCommand = new MySqlCommand();
        myCommand.Connection = connection;
        if(!string.IsNullOrEmpty(key)){
            myCommand.CommandText = @"select * from tbl_company where aae902='0' and aae905='1' and aae904 = 1 and aae906 is null and company like '%"+key+"%' order by id desc";
        }else{
            myCommand.CommandText = @"select * from tbl_company where aae902='0' and aae905='1' and aae904 = 1 and aae906 is null order by id desc";//未同步,未从中间库取走并且状态为新增的
            }
        DataTable data = new DataTable();
        MySqlDataAdapter adapter = new MySqlDataAdapter(myCommand);
        adapter.Fill(data);
        connection.Close();
        return data;
    }
    //手动关联已经存在人才网的企业 sc_handsync为手动同步标志，0为手动同步，1为批量导入
    public int insertCompany(Hashtable ht)
    {
        int res = 0;
        int syncRes = 0;
        Open();
        SqlCommand myCommand = new SqlCommand();
        myCommand.Connection = MyConnection;
        SqlTransaction MyTrans = MyConnection.BeginTransaction("sync");
        myCommand.Transaction = MyTrans;
        try
        {
            myCommand.CommandText = @"if exists (select sc_company_id from f_company_synccompanys where sc_company_id = @cu_no) 
update f_company_synccompanys set sc_business_id = @business_id , sc_company_id = @cu_no , sc_handsync = 0 ,sc_lastmodifytime = getdate(),sc_delete=0 where sc_company_id=@cu_no  
else 
insert into f_company_synccompanys (sc_id,sc_company_id,sc_business_id,sc_lastmodifytime,sc_handsync,sc_delete) 
    values(newid(),@cu_no,@business_id,getdate(),0,0)";

            myCommand.Parameters.Add(new SqlParameter("@business_id", ht["sc_business_id"]));
            myCommand.Parameters.Add(new SqlParameter("@cu_no", ht["cu_no"]));

            res = res + myCommand.ExecuteNonQuery();
            myCommand.CommandText = "update companyuser set cu_sync_id=@business_id,cu_ok='1',cu_state='1',cu_kind='1',cu_hide='0' where cu_no=@cu_no";
            res = res + myCommand.ExecuteNonQuery();
            myCommand.Parameters.Clear();
            if (res > 0)
            {
                string sql = "update tbl_company set aae902=@aae902,aae906=NOW() where businessuser_id=@id";
                syncRes = SqlHelper.ExecuteNonQuery(sql, new MySqlParameter("@aae902", "1"),
                    new MySqlParameter("@id", ht["sc_business_id"])
                    );
                if (syncRes > 0) {
                    MyTrans.Commit();
                }
                else if (syncRes <= 0) {
                    MyTrans.Rollback("sync");
                }
            }
            else {
                res = -1;
                MyTrans.Rollback("sync");
            };

        }
        catch (Exception ex)
        {
            MyTrans.Rollback("sync");
            Close();
            res = -1;
            return res;
        }
        Close();
        return res;
    }
    //查看已经同步的企业
    public DataTable showSyncCompanys()
    {
        Open();
        SqlCommand myCommand = new SqlCommand();
        myCommand.Connection = MyConnection;
        myCommand.CommandText = "select * from f_company_synccompanys left join companyuser on sc_company_id = cu_no where sc_delete=0";
        DataTable data = new DataTable();
        SqlDataAdapter adapter = new SqlDataAdapter(myCommand);
        adapter.Fill(data);
        Close();
        return data;
    }

    //    //导入剩余未同步企业
    //    public int importCompanys(ArrayList data)
    //    {
    //        int res = 0;
    //        int tranRes = 0;
    //        Open();
    //        SqlTransaction MyTrans = MyConnection.BeginTransaction("Trans");
    //        SqlCommand cmd = MyConnection.CreateCommand();
    //        cmd.Transaction = MyTrans;
    //        cmd.CommandText = @"insert into companyuser (cu_name,cu_trade,cu_property,cu_area,cu_postcode,cu_contact,cu_tel,cu_fax,cu_email
    //,cu_url,cu_address,cu_introduce,cu_regtime,cu_modifytime,cu_sync_id,cu_ok,cu_state) values 
    //(@company,@industry,@companyproperty,@region,@zipcode,@contacts,@contactphone,
    //@faxphone,@email,@website,@address,@businessprofile,@createtime,@modifiedtime,@businessuser_id,'1','1')";
    //        try
    //        {
    //            for (int i = 0; i <= data.Count; i++)
    //            {
    //                Hashtable ht = new Hashtable();
    //                ht = (Hashtable)data[i];
    //                cmd.Parameters.Clear();
    //                cmd.Parameters.Add(new SqlParameter("@company", SqlHelper.toDBNull(ht["company"])));
    //                cmd.Parameters.Add(new SqlParameter("@industry", SqlHelper.toDBNull(ht["industry"])));
    //                cmd.Parameters.Add(new SqlParameter("@companyproperty", SqlHelper.toDBNull(ht["companyproperty"])));
    //                cmd.Parameters.Add(new SqlParameter("@region", SqlHelper.toDBNull(ht["region"])));
    //                cmd.Parameters.Add(new SqlParameter("@zipcode", SqlHelper.toDBNull(ht["zipcode"])));
    //                cmd.Parameters.Add(new SqlParameter("@contacts", SqlHelper.toDBNull(ht["contacts"])));
    //                cmd.Parameters.Add(new SqlParameter("@contactphone", SqlHelper.toDBNull(ht["contactphone"])));
    //                cmd.Parameters.Add(new SqlParameter("@faxphone", SqlHelper.toDBNull(ht["faxphone"])));
    //                cmd.Parameters.Add(new SqlParameter("@email", SqlHelper.toDBNull(ht["email"])));
    //                cmd.Parameters.Add(new SqlParameter("@website", SqlHelper.toDBNull(ht["website"])));
    //                cmd.Parameters.Add(new SqlParameter("@address", SqlHelper.toDBNull(ht["address"])));
    //                cmd.Parameters.Add(new SqlParameter("@businessprofile", SqlHelper.toDBNull(ht["businessprofile"])));
    //                cmd.Parameters.Add(new SqlParameter("@createtime", SqlHelper.toDBNull(ht["createtime"])));
    //                cmd.Parameters.Add(new SqlParameter("@modifiedtime", SqlHelper.toDBNull(ht["modifiedtime"])));
    //                cmd.Parameters.Add(new SqlParameter("@businessuser_id", ht["businessuser_id"]));
    //                tranRes = cmd.ExecuteNonQuery();
    //                res += tranRes;
    //                cmd.CommandText = "Insert into f_company_synccompanys(sc_id,sc_company_id,sc_business_id,aae902,aae903,aae904,aae906) select newid(),cu_no,cu_sync_id,'1',GETDATE(),'1',convert(nvarchar(10),getdate(),120) from companyuser where cu_sync_id is not null and cu_sync_id not in (select sc_business_id from f_company_synccompanys)";
    //                cmd.ExecuteNonQuery();
    //                if (tranRes > 0)
    //                {

    //                    string mySql = "UPDATE tbl_company SET aae902='1',aae903=NOW(),aae905='0',aae906=CURDATE() WHERE aae904='1' AND aae905='1' AND businessuser_id = @businessuser_id";
    //                    SqlHelper.ExecuteNonQuery(mySql, new MySqlParameter("@businessuser_id", SqlHelper.toDBNull(ht["businessuser_id"])));
    //                    MyTrans.Commit();
    //                }else{
    //                    MyTrans.Rollback("Trans");
    //                }
    //            }
    //        }
    //        catch (Exception e)
    //        {
    //            res = 0;
    //        }
    //        finally
    //        {
    //            Close();
    //        }

    //        return res;
    //    }
    //导入剩余未同步企业    12 吴兴 13 南浔 14 德清 15 长兴 16 安吉
    public int importCompanys()
    {
        int res = 0;
        int tranRes = 0;
        MySqlConnection connection = new MySqlConnection(ConfigurationManager.AppSettings["TzysMySqlConnectionString"]);
        string sql = "select * from tbl_company where aae902='0' and aae904='1' and aae905='1' and aae906 is null";
        connection.Open();
        MySqlTransaction MySqlTrans = connection.BeginTransaction();
        MySqlCommand myCmd = connection.CreateCommand();
        myCmd.CommandText = sql;
        myCmd.Transaction = MySqlTrans;
        DataTable syncDt = new DataTable();
        MySqlDataAdapter syncAdapter = new MySqlDataAdapter(myCmd);
        syncAdapter.Fill(syncDt);

        Open();
        SqlTransaction MyTrans = MyConnection.BeginTransaction("Trans");
        SqlCommand cmd = MyConnection.CreateCommand();
        cmd.Transaction = MyTrans;

        try
        {
            for (int i = 0; i < syncDt.Rows.Count;i++ ) {
                
                    //安全起见，判断是否有未删除，已经存在的同步企业信息
                    cmd.CommandText = @"if exists (select sc_business_id from f_company_synccompanys where sc_business_id = @businessuser_id and sc_delete =0)
update companyuser set cu_name=@company,cu_trade=@industry,cu_property=@companyproperty,cu_area=@region,cu_postcode=@zipcode,cu_contact=@contacts,cu_tel=@contactphone,cu_fax=@faxphone,cu_email=@email
,cu_url=@website,cu_address=@address,cu_introduce=@businessprofile,cu_regtime=@createtime,cu_modifytime=@modifiedtime,cu_ok='1',cu_state='1',cu_kind='1',cu_hide='0',cu_effecttime=90,cu_apptime=getdate() where cu_sync_id=@businessuser_id and cu_user is null 
                else 
                insert into companyuser (cu_name,cu_trade,cu_property,cu_area,cu_postcode,cu_contact,cu_tel,cu_fax,cu_email
,cu_url,cu_address,cu_introduce,cu_regtime,cu_modifytime,cu_sync_id,cu_ok,cu_state,cu_kind,cu_hide,cu_effecttime,cu_apptime) values 
(@company,@industry,@companyproperty,@region,@zipcode,@contacts,@contactphone,
@faxphone,@email,@website,@address,@businessprofile,@createtime,@modifiedtime,@businessuser_id,'1','1','1','0',90,getdate())
";
                    cmd.Parameters.Add(new SqlParameter("@company", SqlHelper.toDBNull(syncDt.Rows[i]["company"])));
                    cmd.Parameters.Add(new SqlParameter("@industry", SqlHelper.toDBNull(syncDt.Rows[i]["industry"])));
                    cmd.Parameters.Add(new SqlParameter("@companyproperty", SqlHelper.toDBNull(syncDt.Rows[i]["companyproperty"])));
                    cmd.Parameters.Add(new SqlParameter("@region", SqlHelper.toDBNull(syncDt.Rows[i]["region"])));
                    cmd.Parameters.Add(new SqlParameter("@zipcode", SqlHelper.toDBNull(syncDt.Rows[i]["zipcode"])));
                    cmd.Parameters.Add(new SqlParameter("@contacts", SqlHelper.toDBNull(syncDt.Rows[i]["contacts"])));
                    cmd.Parameters.Add(new SqlParameter("@contactphone", SqlHelper.toDBNull(syncDt.Rows[i]["contactphone"])));
                    cmd.Parameters.Add(new SqlParameter("@faxphone", SqlHelper.toDBNull(syncDt.Rows[i]["faxphone"])));
                    cmd.Parameters.Add(new SqlParameter("@email", SqlHelper.toDBNull(syncDt.Rows[i]["email"])));
                    cmd.Parameters.Add(new SqlParameter("@website", SqlHelper.toDBNull(syncDt.Rows[i]["website"])));
                    cmd.Parameters.Add(new SqlParameter("@address", SqlHelper.toDBNull(syncDt.Rows[i]["address"])));
                    cmd.Parameters.Add(new SqlParameter("@businessprofile", SqlHelper.toDBNull(syncDt.Rows[i]["businessprofile"])));
                    cmd.Parameters.Add(new SqlParameter("@createtime", SqlHelper.toDBNull(syncDt.Rows[i]["createtime"])));
                    cmd.Parameters.Add(new SqlParameter("@modifiedtime", SqlHelper.toDBNull(syncDt.Rows[i]["modifiedtime"])));
                    cmd.Parameters.Add(new SqlParameter("@businessuser_id", syncDt.Rows[i]["businessuser_id"]));
                    res = cmd.ExecuteNonQuery();
                    cmd.Parameters.Clear();
                //如果有更新，则把新企业插入到关联表中，未做详细判断，只判断同步企业不存在关联表中，并且未被删除
                    if (res > 0)
                    {
                        cmd.CommandText = "Insert into f_company_synccompanys(sc_id,sc_company_id,sc_business_id,sc_handsync,sc_delete,sc_lastmodifytime) select newid(),cu_no,cu_sync_id,1,0,getdate() from companyuser where cu_sync_id is not null and cu_sync_id not in (select sc_business_id from f_company_synccompanys where sc_delete = 0)";
                        res += cmd.ExecuteNonQuery();
                //如果有更新，则更新中间库，设置更新企业已经同步，并设置数据取走的时间
                        myCmd.CommandText = "update tbl_company set aae902 = '1',aae906=NOW() where businessuser_id = @businessuser_id";
                        myCmd.Parameters.Add("@businessuser_id",syncDt.Rows[i]["businessuser_id"]);
                        tranRes = myCmd.ExecuteNonQuery();
                        myCmd.Parameters.Clear();
                    }
                }
                //else if ("0" == reader["aae904"].ToString())
                //{
                //    cmd.CommandText = "update companyuser set cu_state = -1,cu_hide='1' where cu_sync_id = @businessuser_id and cu_user is null";
                //    cmd.ExecuteNonQuery();
                //}

            
                //再次判断，如果中间库未更新，则回滚，都不更新
                if(res>0 && tranRes>0){
                    MyTrans.Commit();
                    MySqlTrans.Commit();
                }
                else
                {
                    MyTrans.Rollback("Trans");
                    MySqlTrans.Rollback();
                }
        }catch(Exception e){
            res = -1;
            MyTrans.Rollback("Trans");
            MySqlTrans.Rollback();
            Close();
            connection.Close();
            return res;
        }
        Close();
        connection.Close();
        return res;
    }
    public int importSingleCompany(Hashtable ht)
    {
        //查询
        int res = 0;
        int syncRes = 0;
        MySqlConnection connection = new MySqlConnection(ConfigurationManager.AppSettings["TzysMySqlConnectionString"]);
        connection.Open();
        MySqlTransaction MySqlTrans = connection.BeginTransaction();
        MySqlCommand myCmd = connection.CreateCommand();
        myCmd.Transaction = MySqlTrans;
        //SQLSERVER
        Open();
        SqlCommand myCommand = new SqlCommand();
        myCommand.Connection = MyConnection;
        SqlTransaction MyTrans = MyConnection.BeginTransaction("sync");
        myCommand.Transaction = MyTrans;
        try
        {
            if (ht!=null)
            {

                //安全起见，判断是否有未删除，已经存在的同步企业信息
                myCommand.CommandText = @"if exists (select sc_business_id from f_company_synccompanys where sc_business_id = @businessuser_id and sc_delete =0)
update companyuser set cu_name=@company,cu_trade=@industry,cu_property=@companyproperty,cu_area=@region,cu_postcode=@zipcode,cu_contact=@contacts,cu_tel=@contactphone,cu_fax=@faxphone,cu_email=@email
,cu_url=@website,cu_address=@address,cu_introduce=@businessprofile,cu_regtime=@createtime,cu_modifytime=@modifiedtime,cu_ok='1',cu_state='1',cu_kind='1',cu_hide='0',cu_effecttime=90,cu_apptime=getdate() where cu_sync_id=@businessuser_id and cu_user is null 
                else 
                insert into companyuser (cu_name,cu_trade,cu_property,cu_area,cu_postcode,cu_contact,cu_tel,cu_fax,cu_email
,cu_url,cu_address,cu_introduce,cu_regtime,cu_modifytime,cu_sync_id,cu_ok,cu_state,cu_kind,cu_hide,cu_effecttime,cu_apptime) values 
(@company,@industry,@companyproperty,@region,@zipcode,@contacts,@contactphone,
@faxphone,@email,@website,@address,@businessprofile,@createtime,@modifiedtime,@businessuser_id,'1','1','1','0',90,getdate())
";
                myCommand.Parameters.Add(new SqlParameter("@company", SqlHelper.toDBNull(ht["company"])));
                myCommand.Parameters.Add(new SqlParameter("@industry", SqlHelper.toDBNull(ht["industry"])));
                myCommand.Parameters.Add(new SqlParameter("@companyproperty", SqlHelper.toDBNull(ht["companyproperty"])));
                myCommand.Parameters.Add(new SqlParameter("@region", SqlHelper.toDBNull(ht["region"])));
                myCommand.Parameters.Add(new SqlParameter("@zipcode", SqlHelper.toDBNull(ht["zipcode"])));
                myCommand.Parameters.Add(new SqlParameter("@contacts", SqlHelper.toDBNull(ht["contacts"])));
                myCommand.Parameters.Add(new SqlParameter("@contactphone", SqlHelper.toDBNull(ht["contactphone"])));
                myCommand.Parameters.Add(new SqlParameter("@faxphone", SqlHelper.toDBNull(ht["faxphone"])));
                myCommand.Parameters.Add(new SqlParameter("@email", SqlHelper.toDBNull(ht["email"])));
                myCommand.Parameters.Add(new SqlParameter("@website", SqlHelper.toDBNull(ht["website"])));
                myCommand.Parameters.Add(new SqlParameter("@address", SqlHelper.toDBNull(ht["address"])));
                myCommand.Parameters.Add(new SqlParameter("@businessprofile", SqlHelper.toDBNull(ht["businessprofile"])));
                myCommand.Parameters.Add(new SqlParameter("@createtime", SqlHelper.toDBNull(ht["createtime"])));
                myCommand.Parameters.Add(new SqlParameter("@modifiedtime", SqlHelper.toDBNull(ht["modifiedtime"])));
                myCommand.Parameters.Add(new SqlParameter("@businessuser_id", ht["businessuser_id"]));
                res = myCommand.ExecuteNonQuery();
                myCommand.Parameters.Clear();
                //如果有更新，则把新企业插入到关联表中，未做详细判断，只判断同步企业不存在关联表中，并且未被删除
                if (res > 0)
                {
                    myCommand.CommandText = "Insert into f_company_synccompanys(sc_id,sc_company_id,sc_business_id,sc_handsync,sc_delete,sc_lastmodifytime) select newid(),cu_no,cu_sync_id,1,0,getdate() from companyuser where cu_sync_id is not null and cu_sync_id not in (select sc_business_id from f_company_synccompanys where sc_delete = 0)";
                    res += myCommand.ExecuteNonQuery();
                    //如果有更新，则更新中间库，设置更新企业已经同步，并设置数据取走的时间
                    myCmd.CommandText = "update tbl_company set aae902 = '1',aae906=NOW() where businessuser_id = @businessuser_id";
                    myCmd.Parameters.Add("@businessuser_id", ht["businessuser_id"]);
                    syncRes = myCmd.ExecuteNonQuery();
                    myCmd.Parameters.Clear();
                }
            }
            //else if ("0" == reader["aae904"].ToString())
            //{
            //    cmd.CommandText = "update companyuser set cu_state = -1,cu_hide='1' where cu_sync_id = @businessuser_id and cu_user is null";
            //    cmd.ExecuteNonQuery();
            //}


            //再次判断，如果中间库未更新，则回滚，都不更新
            if (res > 0 && syncRes > 0)
            {
                MyTrans.Commit();
                MySqlTrans.Commit();
            }
            else
            {
                MyTrans.Rollback("sync");
                MySqlTrans.Rollback();
            }
        }
        catch (Exception e)
        {
            res = -1;
            MyTrans.Rollback("sync");
            MySqlTrans.Rollback();
            Close();
            connection.Close();
            return res;
        }
        Close();
        connection.Close();
        return res;
    }
    //企业缴费
    //public int addNewPay() {
    //    Open();
    //    SqlCommand myCommand = new SqlCommand();
    //    myCommand.Connection = MyConnection;
    //    SqlTransaction MyTrans = MyConnection.BeginTransaction("sync");
    //    myCommand.Transaction = MyTrans;
    //}

    //public DataTable GetBasicService(String pid) {
    //    SqlCommand cmd = Open().CreateCommand();
    //    if (!String.IsNullOrEmpty(pid))
    //    {
    //        cmd.CommandText = "select * from ItemOfFees where ps_pid = " + pid;
    //    }
    //    else {
    //        cmd.CommandText = "select * from ItemOfFees where ps_pid <> 100 ";
    //    }

    //    DataTable data = new DataTable();
    //    SqlDataAdapter adapter = new SqlDataAdapter(cmd);
    //    adapter.Fill(data);
    //    Close();
    //    return data;
    //}
    /*
    ---------------------------
来自网页的消息
---------------------------
{"cu_name":"","cu_address":"","cu_license":"","cu_contact":"","cu_tel":"","cu_email":"","cu_introduce":"","cu_no":"","fee_id":1,"expense":"777"}
---------------------------
确定   
---------------------------

        
        
        */
    public string SavePay(ArrayList ht) {
        SqlCommand cmd = Open().CreateCommand();
        cmd.CommandText = @"insert into orderoffees(
       [of_id]
      ,[of_orderid]
      ,[of_cuno]
      ,[of_psid]
      ,[of_cost]
      ,[of_createtime]
      ,[of_isDel]
 ) values (
       newid()
      ,@of_orderid
      ,@of_cuno
      ,@of_psid
      ,@of_cost
      ,@of_createtime
      ,@of_isDel)";
        try
        {
            string orderid = Guid.NewGuid().ToString();
            for (int i = 0; i < ht.Count; i++)
            {
                Hashtable ht1 = (Hashtable)ht[i];
                cmd.Parameters.Add(new SqlParameter("@of_orderid", orderid));
                cmd.Parameters.Add(new SqlParameter("@of_cuno", SqlHelper.toDBNull(ht1["cu_no"])));
                cmd.Parameters.Add(new SqlParameter("@of_psid", SqlHelper.toDBNull(ht1["fee_id"])));
                cmd.Parameters.Add(new SqlParameter("@of_cost", SqlHelper.toDBNull(ht1["expense"])));
                cmd.Parameters.Add(new SqlParameter("@of_createtime", DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss")));
                cmd.Parameters.Add(new SqlParameter("@of_isDel", false));
                cmd.ExecuteNonQuery();
                cmd.Parameters.Clear();
            }
            return "保存成功！";
        }
        catch(Exception e)
        {
            Console.WriteLine(e.Message);
            return "保存失败！";
        }
    }

    public DataTable GetPayInfo() {
        SqlCommand cmd = Open().CreateCommand();
        cmd.CommandText = "select * from companyPay left join payservice on cp_psID=ps_ID left join companyuser on cp_cuno=cu_no";
        DataTable dt = new DataTable();
        SqlDataAdapter adapter = new SqlDataAdapter(cmd);
        adapter.Fill(dt);
        return dt;
    }
}
